ampersand-state
Advanced tools
Comparing version 4.3.14 to 4.3.15
@@ -286,3 +286,4 @@ /*$AMPERSAND_VERSION*/ | ||
def = this._definition[attr]; | ||
isEqual = this._getCompareForType(def && def.type); | ||
if (!def) continue; | ||
isEqual = this._getCompareForType(def.type); | ||
if (isEqual(old[attr], (val = diff[attr]))) continue; | ||
@@ -289,0 +290,0 @@ (changed || (changed = {}))[attr] = val; |
{ | ||
"name": "ampersand-state", | ||
"description": "An observable, extensible state object with derived watchable properties.", | ||
"version": "4.3.14", | ||
"version": "4.3.15", | ||
"author": "Henrik Joreteg <henrik@andyet.net>", | ||
@@ -6,0 +6,0 @@ "browserify": { |
@@ -56,2 +56,14 @@ # ampersand-state | ||
`AmpersandState.extend` does more than just copy attributes from one prototype to another. As such it is incompatible with Coffeescript's class-based extend. TypeScript users may have similar issues. | ||
For instance, this will not work since it never actually calls `AmpersandState.extend`: | ||
``` | ||
class Foo extends AmpersandView | ||
constructor: (options)-> | ||
@special = options.special | ||
super | ||
``` | ||
### constructor/initialize `new AmpersandState([attrs], [options])` | ||
@@ -501,2 +513,4 @@ | ||
Note that if passing an attributes object to diff against, only changes to properties defined on the model will be detected. This means that changes to children or collections will *not* be returned as changes by this method. | ||
### toJSON `state.toJSON()` | ||
@@ -503,0 +517,0 @@ |
@@ -1395,1 +1395,29 @@ var tape = require('tape'); | ||
}); | ||
test("#96 - changedAttributes includes properties that are not direct model attributes", function(t) { | ||
var Submodel = State.extend({ | ||
props: { | ||
b: 'number' | ||
} | ||
}); | ||
var Model = State.extend({ | ||
props: { | ||
a: 'number' | ||
}, | ||
children: { | ||
submodels: Submodel | ||
} | ||
}); | ||
var model = new Model({ a: 1 }); | ||
var old = JSON.parse(JSON.stringify(model)); | ||
var diff = model.changedAttributes(old); | ||
t.ok(diff === false, 'should return false'); | ||
diff = model.changedAttributes({ a: 5, submodels: [] }); | ||
t.ok(diff.hasOwnProperty('a'), 'should return the changed `a`'); | ||
t.ok(!diff.hasOwnProperty('submodels'), 'should not return `submodels`'); | ||
t.end(); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
112909
2846
540