Comparing version 2.0.3 to 2.1.0
{ | ||
"name": "diff-dom", | ||
"main": "diffDOM.js", | ||
"version": "2.0.3", | ||
"version": "2.1.0", | ||
"homepage": "https://github.com/fiduswriter/diffDOM", | ||
@@ -6,0 +6,0 @@ "authors": [ |
@@ -447,3 +447,4 @@ (function() { | ||
preDiffApply: function () {}, | ||
postDiffApply: function () {} | ||
postDiffApply: function () {}, | ||
filterOuterDiff: null | ||
}, | ||
@@ -465,2 +466,5 @@ i; | ||
}; | ||
diffDOM.Diff = Diff; | ||
diffDOM.prototype = { | ||
@@ -514,3 +518,3 @@ | ||
findNextDiff: function(t1, t2, route) { | ||
var diffs; | ||
var diffs, fdiffs; | ||
@@ -523,2 +527,6 @@ if (this.maxDepth && route.length > this.maxDepth) { | ||
diffs = this.findOuterDiff(t1, t2, route); | ||
if (this.filterOuterDiff) { | ||
fdiffs = this.filterOuterDiff(t1, t2, diffs); | ||
if (fdiffs) diffs = fdiffs; | ||
} | ||
if (diffs.length > 0) { | ||
@@ -574,3 +582,3 @@ t1.outerDone = true; | ||
return [new Diff({ | ||
action: 'modifyComment', | ||
action: 'modifyTextElement', | ||
route: route, | ||
@@ -582,3 +590,3 @@ oldValue: t1.data, | ||
return [new Diff({ | ||
action: 'modifyTextElement', | ||
action: 'modifyComment', | ||
route: route, | ||
@@ -717,7 +725,10 @@ oldValue: t1.data, | ||
if (subtrees.length > 1) { | ||
/* Two or more groups have been identified among the childnodes of t1 | ||
if (subtrees.length > 0) { | ||
/* One or more groups have been identified among the childnodes of t1 | ||
* and t2. | ||
*/ | ||
return this.attemptGroupRelocation(t1, t2, subtrees, route); | ||
diffs = this.attemptGroupRelocation(t1, t2, subtrees, route); | ||
if (diffs.length > 0) { | ||
return diffs; | ||
} | ||
} | ||
@@ -836,2 +847,3 @@ | ||
})); | ||
return diffs; | ||
} | ||
@@ -1023,3 +1035,3 @@ } | ||
if (diff.name === 'checked') { | ||
delete node.checked; | ||
node.checked = false; | ||
} else if (diff.name === 'selected') { | ||
@@ -1026,0 +1038,0 @@ delete node.selected; |
{ | ||
"name": "diff-dom", | ||
"version": "2.0.3", | ||
"version": "2.1.0", | ||
"description": "A diff for DOM elements, as client-side JavaScript code. Gets all modifications, insertions and removals between two DOM fragments.", | ||
@@ -5,0 +5,0 @@ "main": "diffDOM.js", |
@@ -135,2 +135,19 @@ # diffDOM - A JavaScript diffing algorithm for DOM elements | ||
#### Outer and Inner diff hooks | ||
diffDOM also provides a way to filter outer diff | ||
``` | ||
dd = new diffDOM({ | ||
filterOuterDiff: function(t1, t2, diffs) { | ||
// can change current outer diffs by returning a new array, | ||
// or by mutating outerDiffs. | ||
if (!diffs.length && t1.nodeName == "my-component" && t2.nodeName == t1.nodeName) { | ||
// will not diff childNodes | ||
t1.innerDone = true; | ||
} | ||
} | ||
}); | ||
``` | ||
#### Debugging | ||
@@ -137,0 +154,0 @@ |
Sorry, the diff of this file is not supported yet
302888
1340
171