Skip to content

Commit b430a46

Browse files
committed
remove JavaScript reserved keywords, replaces #39
1 parent 85c2375 commit b430a46

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

diffDOM.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,19 @@
4949
};
5050

5151
var SubsetMapping = function SubsetMapping(a, b) {
52-
this.old = a;
53-
this.new = b;
52+
this.oldValue = a;
53+
this.newValue = b;
5454
};
5555

5656
SubsetMapping.prototype = {
5757
contains: function contains(subset) {
5858
if (subset.length < this.length) {
59-
return subset.new >= this.new && subset.new < this.new + this.length;
59+
return subset.newValue >= this.newValue && subset.newValue < this.newValue + this.length;
6060
}
6161
return false;
6262
},
6363
toString: function toString() {
64-
return this.length + " element subset, first mapping: old " + this.old + " → new " + this.new;
64+
return this.length + " element subset, first mapping: old " + this.oldValue + " → new " + this.newValue;
6565
}
6666
};
6767

@@ -70,8 +70,8 @@
7070
if (el.nodeName !== '#text' && el.nodeName !== '#comment') {
7171
output.push(el.nodeName);
7272
if (el.attributes) {
73-
if (el.attributes.class) {
74-
output.push(el.nodeName + '.' + el.attributes.class.replace(/ /g, '.'));
73+
if (el.attributes['class']) {
74+
output.push(el.nodeName + '.' + el.attributes['class'].replace(/ /g, '.'));
7575
}
7676
if (el.attributes.id) {
7777
output.push(el.nodeName + '#' + el.attributes.id);
@@ -214,8 +214,8 @@
214214
return true;
215215
}
216216
}
217-
if (e1.attributes.class && e1.attributes.class === e2.attributes.class) {
218-
var classDescriptor = e1.nodeName + '.' + e1.attributes.class.replace(/ /g, '.');
217+
if (e1.attributes['class'] && e1.attributes['class'] === e2.attributes['class']) {
218+
var classDescriptor = e1.nodeName + '.' + e1.attributes['class'].replace(/ /g, '.');
219219
if (classDescriptor in uniqueDescriptors) {
220220
return true;
221221
}
@@ -353,12 +353,12 @@
353353

354354
// give elements from the same subset the same group number
355355
stable.forEach(function(subset) {
356-
var i, endOld = subset.old + subset.length,
357-
endNew = subset.new + subset.length;
358-
for (i = subset.old; i < endOld; i += 1) {
356+
var i, endOld = subset.oldValue + subset.length,
357+
endNew = subset.newValue + subset.length;
358+
for (i = subset.oldValue; i < endOld; i += 1) {
359359
gaps1[i] = group;
360360
}
361-
for (i = subset.new; i < endNew; i += 1) {
361+
for (i = subset.newValue; i < endNew; i += 1) {
362362
gaps2[i] = group;
363363
}
364364
group += 1;
@@ -385,8 +385,8 @@
385385
return arguments[1];
386386
},
387387
markBoth = function(i) {
388-
marked1[subset.old + i] = true;
389-
marked2[subset.new + i] = true;
388+
marked1[subset.oldValue + i] = true;
389+
marked2[subset.newValue + i] = true;
390390
};
391391

392392
while (subset) {
@@ -875,20 +875,20 @@
875875
}
876876
// group relocation
877877
group = subtrees[gaps1[index2]];
878-
toGroup = Math.min(group.new, (t1.childNodes.length - group.length));
879-
if (toGroup !== group.old) {
878+
toGroup = Math.min(group.newValue, (t1.childNodes.length - group.length));
879+
if (toGroup !== group.oldValue) {
880880
// Check whether destination nodes are different than originating ones.
881881
destinationDifferent = false;
882882
for (j = 0; j < group.length; j += 1) {
883-
if (!roughlyEqual(t1.childNodes[toGroup + j], t1.childNodes[group.old + j], [], false, true)) {
883+
if (!roughlyEqual(t1.childNodes[toGroup + j], t1.childNodes[group.oldValue + j], [], false, true)) {
884884
destinationDifferent = true;
885885
}
886886
}
887887
if (destinationDifferent) {
888888
return [new Diff({
889889
action: 'relocateGroup',
890890
groupLength: group.length,
891-
from: group.old,
891+
from: group.oldValue,
892892
to: toGroup,
893893
route: route
894894
})];

0 commit comments

Comments
 (0)