Skip to content

Commit 2e4f075

Browse files
committed
jsbeautify
1 parent 1cc3556 commit 2e4f075

File tree

2 files changed

+18
-24
lines changed

2 files changed

+18
-24
lines changed

diffDOM.js

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
var diffcount;
55

6-
var Diff = function (options) {
6+
var Diff = function(options) {
77
var diff = this;
88
Object.keys(options).forEach(function(option) {
99
diff[option] = options[option];
@@ -441,10 +441,10 @@
441441
},
442442
// empty functions were benchmarked as running faster than both
443443
// `f && f()` and `if (f) { f(); }`
444-
preVirtualDiffApply: function () {},
445-
postVirtualDiffApply: function () {},
446-
preDiffApply: function () {},
447-
postDiffApply: function () {},
444+
preVirtualDiffApply: function() {},
445+
postVirtualDiffApply: function() {},
446+
preDiffApply: function() {},
447+
postDiffApply: function() {},
448448
filterOuterDiff: null
449449
},
450450
i;
@@ -616,24 +616,22 @@
616616
}));
617617
}
618618
}
619-
620619
});
621620

622-
623621
attr2.forEach(function(attr) {
624622
diffs.push(new Diff({
625623
action: 'addAttribute',
626624
route: route,
627625
name: attr,
628626
value: t2.attributes[attr]
629627
}));
630-
631628
});
632629

633630
return diffs;
634631
},
635632
nodeToObj: function(node) {
636-
var objNode = {}, dobj = this;
633+
var objNode = {},
634+
dobj = this;
637635
objNode.nodeName = node.nodeName;
638636
if (objNode.nodeName === '#text' || objNode.nodeName === '#comment') {
639637
objNode.data = node.data;
@@ -720,10 +718,10 @@
720718
/* One or more groups have been identified among the childnodes of t1
721719
* and t2.
722720
*/
723-
diffs = this.attemptGroupRelocation(t1, t2, subtrees, route);
724-
if (diffs.length > 0) {
725-
return diffs;
726-
}
721+
diffs = this.attemptGroupRelocation(t1, t2, subtrees, route);
722+
if (diffs.length > 0) {
723+
return diffs;
724+
}
727725
}
728726

729727
/* 0 or 1 groups of similar child nodes have been found
@@ -910,7 +908,6 @@
910908
}
911909
return diffs;
912910
},
913-
914911
findValueDiff: function(t1, t2, route) {
915912
// Differences of value. Only useful if the value/selection/checked value
916913
// differs from what is represented in the DOM. For example in the case
@@ -990,7 +987,9 @@
990987
node: node
991988
};
992989

993-
if (this.preVirtualDiffApply(info)) { return true; }
990+
if (this.preVirtualDiffApply(info)) {
991+
return true;
992+
}
994993

995994
switch (diff.action) {
996995
case 'addAttribute':
@@ -1016,7 +1015,6 @@
10161015
}
10171016
break;
10181017
case 'removeAttribute':
1019-
10201018
delete node.attributes[diff.name];
10211019

10221020
if (Object.keys(node.attributes).length === 0) {
@@ -1115,17 +1113,12 @@
11151113
default:
11161114
console.log('unknown action');
11171115
}
1118-
11191116
// capture newNode for the callback
11201117
info.newNode = newNode;
11211118
this.postVirtualDiffApply(info);
1122-
11231119
return;
11241120
},
11251121

1126-
1127-
1128-
11291122
// ===== Apply a diff =====
11301123

11311124
apply: function(tree, diffs) {
@@ -1163,7 +1156,9 @@
11631156
node: node
11641157
};
11651158

1166-
if (this.preDiffApply(info)) { return true; }
1159+
if (this.preDiffApply(info)) {
1160+
return true;
1161+
}
11671162

11681163
switch (diff.action) {
11691164
case 'addAttribute':
@@ -1278,7 +1273,6 @@
12781273
});
12791274
},
12801275
undoDiff: function(tree, diff) {
1281-
12821276
switch (diff.action) {
12831277
case 'addAttribute':
12841278
diff.action = 'removeAttribute';

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "diff-dom",
3-
"version": "2.1.1",
3+
"version": "2.1.0",
44
"description": "A diff for DOM elements, as client-side JavaScript code. Gets all modifications, insertions and removals between two DOM fragments.",
55
"main": "diffDOM.js",
66
"directories": {

0 commit comments

Comments
 (0)