Skip to content

Commit 40e1042

Browse files
author
massimosarchi
committed
minifiers support
Quick and dirty workaround in order to get rid of ‘new’ and ‘class’ javascript reserved keywords which prevent most used compressors to work. It would be better to change property names.
1 parent 6fdb82c commit 40e1042

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

diffDOM.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,18 @@
5050

5151
var SubsetMapping = function SubsetMapping(a, b) {
5252
this.old = a;
53-
this.new = b;
53+
this['new'] = 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['new'] >= this['new'] && subset['new'] < this['new'] + 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.old + " → new " + this['new'];
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
}
@@ -354,11 +354,11 @@
354354
// give elements from the same subset the same group number
355355
stable.forEach(function(subset) {
356356
var i, endOld = subset.old + subset.length,
357-
endNew = subset.new + subset.length;
357+
endNew = subset['new'] + subset.length;
358358
for (i = subset.old; i < endOld; i += 1) {
359359
gaps1[i] = group;
360360
}
361-
for (i = subset.new; i < endNew; i += 1) {
361+
for (i = subset['new']; i < endNew; i += 1) {
362362
gaps2[i] = group;
363363
}
364364
group += 1;
@@ -386,7 +386,7 @@
386386
},
387387
markBoth = function(i) {
388388
marked1[subset.old + i] = true;
389-
marked2[subset.new + i] = true;
389+
marked2[subset['new'] + i] = true;
390390
};
391391

392392
while (subset) {
@@ -875,7 +875,7 @@
875875
}
876876
// group relocation
877877
group = subtrees[gaps1[index2]];
878-
toGroup = Math.min(group.new, (t1.childNodes.length - group.length));
878+
toGroup = Math.min(group['new'], (t1.childNodes.length - group.length));
879879
if (toGroup !== group.old) {
880880
// Check whether destination nodes are different than originating ones.
881881
destinationDifferent = false;

0 commit comments

Comments
 (0)