Skip to content

Commit

Permalink
fix isChanged in update()
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti committed Oct 5, 2015
1 parent 32b7511 commit 23bb904
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ function update(instance, spec) {
}
else {
var newValue = update(value[k], spec[k]);
isChanged = ( newValue !== value[k] );
isChanged = isChanged || ( newValue !== value[k] );
value[k] = newValue;
}
}
Expand Down
6 changes: 5 additions & 1 deletion test/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,12 @@ describe('t.update(instance, spec)', function () {
assert.strictEqual(p1, p3);

var n1 = {a: {b: {c: 1}}};
var n2 = t.update(n1, {a: {b: {c: {$set: 1}}}})
var n2 = t.update(n1, {a: {b: {c: {$set: 1}}}});
assert.strictEqual(n1, n2);

var m1 = {a: 1, b: 2};
var m2 = t.update(m1, {a: {$set: 2}, b: {$set: 2}});
assert.equal(m1 === m2, false);
});

describe('structs', function () {
Expand Down

0 comments on commit 23bb904

Please sign in to comment.