Permalink
Browse files

trigger updated events more

  • Loading branch information...
1 parent 3e5e98e commit a6e7866405a7beecaff28fd33dea68ed6abdac46 @substack committed Feb 11, 2012
Showing with 17 additions and 8 deletions.
  1. +12 −3 index.js
  2. +5 −5 test/html.js
View
@@ -123,9 +123,18 @@ function difflet (opts, prev, next) {
else if (typeof node === 'object'
&& node && typeof node.inspect === 'function') {
this.block();
- if (inserted) set('inserted');
- write(node.inspect());
- if (inserted) unset('inserted');
+ if (inserted) {
+ set('inserted');
+ write(node.inspect());
+ unset('inserted');
+ }
+ else if (!(prevNode && typeof prevNode.inspect === 'function'
+ && prevNode.inspect() === node.inspect())) {
+ set('updated');
+ write(node.inspect());
+ unset('updated');
+ }
+ else write(node.inspect());
}
else if (typeof node == 'object') {
var insertedKey = false;
View
@@ -20,12 +20,11 @@ test('html output', function (t) {
}
});
- function qqq () {}
var stream = diff(
- { yy : 6, zz : 5, a : [1,2,3], fn : qqq },
+ { yy : 6, zz : 5, a : [1,2,3], fn : function qqq () {} },
{
a : [ 1, 2, 3, [4], "z", /beep/, new Buffer([0,1,2]) ],
- fn : 8,
+ fn : function rrr () {},
b : [5,6,7]
}
);
@@ -36,8 +35,9 @@ test('html output', function (t) {
t.equal(data,
'{&quot;a&quot;:[1,2,3,<g>[4]</g>,<g>&quot;z&quot;</g>,'
+ '<g>/beep/</g>,<g>&lt;Buffer 00 01 02&gt;</g>],'
- + '&quot;fn&quot;:<b>8</b>,<g>&quot;b&quot;:[5,6,7]</g>,'
- + '<r>&quot;yy&quot;:6,&quot;zz&quot;:5</r>}'
+ + '&quot;fn&quot;:<b>[Function: rrr]</b>,<g>'
+ + '&quot;b&quot;:[5,6,7]</g>,<r>&quot;yy&quot;:6,'
+ + '&quot;zz&quot;:5</r>}'
);
t.end();
});

0 comments on commit a6e7866

Please sign in to comment.