Tune propertyChanged behavior

This commit is contained in:
Anatoliy Chakkaev 2012-04-11 23:31:10 +04:00
parent 6be57cf454
commit 2ce44db4ba
2 changed files with 2 additions and 2 deletions

View File

@ -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'];
};
/**

View File

@ -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();