mirror of
https://github.com/nasa/openmct.git
synced 2025-04-07 19:34:25 +00:00
Merge pull request #317 from nasa/open316
[bug] TypeImpl.getInitialmodel should always return a fresh (ie. cloned) model.
This commit is contained in:
commit
a7f277b0d2
@ -156,8 +156,15 @@ define(
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the default model for an object of this type. Note that
|
||||
* this method returns a clone of the original model, so if using this
|
||||
* method heavily, consider caching the result to optimize performance.
|
||||
*
|
||||
* @return {object} The default model for an object of this type.
|
||||
*/
|
||||
TypeImpl.prototype.getInitialModel = function () {
|
||||
return this.typeDef.model || {};
|
||||
return JSON.parse(JSON.stringify(this.typeDef.model || {}));
|
||||
};
|
||||
|
||||
TypeImpl.prototype.getDefinition = function () {
|
||||
|
@ -101,6 +101,12 @@ define(
|
||||
expect(type.getInitialModel().someKey).toEqual("some value");
|
||||
});
|
||||
|
||||
it("provides a fresh initial model each time", function () {
|
||||
var model = type.getInitialModel();
|
||||
model.someKey = "some other value";
|
||||
expect(type.getInitialModel().someKey).toEqual("some value");
|
||||
});
|
||||
|
||||
it("provides type properties", function () {
|
||||
expect(type.getProperties().length).toEqual(1);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user