Tune propertyChanged behavior
This commit is contained in:
parent
6be57cf454
commit
2ce44db4ba
|
@ -595,7 +595,7 @@ AbstractClass.prototype.fromObject = function (obj) {
|
|||
* @return Boolean
|
||||
*/
|
||||
AbstractClass.prototype.propertyChanged = function propertyChanged(attr) {
|
||||
return this['_' + attr] !== this[attr + '_was'];
|
||||
return this.hasOwnProperty(attr + '_was') && this['_' + attr] !== this[attr + '_was'];
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -315,7 +315,7 @@ function testOrm(schema) {
|
|||
test.ok(post.propertyChanged('content'));
|
||||
post.reload(function (err, post) {
|
||||
test.equal(post.title, 'New title');
|
||||
test.ok(!post.propertyChanged('title'));
|
||||
test.ok(!post.propertyChanged('title'), 'title not changed');
|
||||
test.equal(post.content, 'content', 'real value turned back');
|
||||
test.ok(!post.propertyChanged('content'), 'content unchanged');
|
||||
test.done();
|
||||
|
|
Loading…
Reference in New Issue