promised-models
Advanced tools
Comparing version 0.0.15 to 0.0.16
@@ -40,4 +40,4 @@ | ||
unset: function () { | ||
this.set(this._callOrGetDefault()); | ||
this._isSet = false; | ||
this.value = this._callOrGetDefault(); | ||
}, | ||
@@ -109,3 +109,5 @@ | ||
set: function (value) { | ||
if (!this.isEqual(value)) { | ||
if (value === null) { | ||
this.unset(); | ||
} else if (!this.isEqual(value)) { | ||
this.value = this.parse(value); | ||
@@ -112,0 +114,0 @@ this._isSet = true; |
{ | ||
"description": "promise based, typed attributes, nested models and collections", | ||
"name": "promised-models", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"repository": "git@github.com:delfrrr/promised-models.git", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -104,2 +104,4 @@ # Promised Models | ||
**Note:** setting `null` is equivalent to call `.unset()` | ||
#### get `model.get(attributeName)` | ||
@@ -106,0 +108,0 @@ |
@@ -68,3 +68,23 @@ var expect = require('chai').expect, | ||
}); | ||
it('should emit change', function (done) { | ||
var model = new ModelClass({ | ||
a: 'a-1' | ||
}); | ||
model.ready().then(function () { | ||
model.on('change:a', function () { | ||
done(); | ||
}); | ||
model.unset('a'); | ||
}).done(); | ||
}); | ||
}); | ||
describe('set', function () { | ||
it('should unset when setting null', function () { | ||
var model = new ModelClass({ | ||
a: 'a-1' | ||
}); | ||
model.set('a', null); | ||
expect(model.get('a')).to.be.equal('a'); | ||
}); | ||
}); | ||
}); |
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
104169
2678
504