Skip to content

Commit

Permalink
Tune propertyChanged behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
1602 committed Apr 11, 2012
1 parent 6be57cf commit 2ce44db
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/abstract-class.js
Expand Up @@ -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'];
};

/**
Expand Down
2 changes: 1 addition & 1 deletion test/common_test.js
Expand Up @@ -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();
Expand Down

0 comments on commit 2ce44db

Please sign in to comment.