Skip to content

Commit 5a9bdfb

Browse files
committed
long variables names by default, add compress option
1 parent 8bb1162 commit 5a9bdfb

File tree

1 file changed

+45
-35
lines changed

1 file changed

+45
-35
lines changed

diffDOM.js

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@
239239
var cloneObj = function(obj) {
240240
// TODO: Do we really need to clone here? Is it not enough to just return the original object?
241241
return JSON.parse(JSON.stringify(obj));
242-
//return obj;
243242
};
244243

245244
/**
@@ -444,9 +443,10 @@
444443
postVirtualDiffApply: function() {},
445444
preDiffApply: function() {},
446445
postDiffApply: function() {},
447-
filterOuterDiff: null
446+
filterOuterDiff: null,
447+
compress: false // Whether to work with compressed diffs
448448
},
449-
i;
449+
varNames, i, j;
450450

451451
if (typeof options === "undefined") {
452452
options = {};
@@ -460,38 +460,49 @@
460460
}
461461
}
462462

463-
this._const = {
464-
addAttribute: 0,
465-
modifyAttribute: 1,
466-
removeAttribute: 2,
467-
modifyTextElement: 3,
468-
relocateGroup: 4,
469-
removeElement: 5,
470-
addElement: 6,
471-
removeTextElement: 7,
472-
addTextElement: 8,
473-
replaceElement: 9,
474-
modifyValue: 10,
475-
modifyChecked: 11,
476-
modifySelected: 12,
477-
modifyComment: 13,
478-
action: 'a',
479-
route: 'r',
480-
oldValue: 'o',
481-
newValue: 'n',
482-
element: 'e',
483-
'group': 'g',
484-
from: 'f',
485-
to: 't',
486-
name: 'na',
487-
value: 'v',
488-
'data': 'd',
489-
'attributes': 'at',
490-
'nodeName': 'nn',
491-
'childNodes': 'c',
492-
'checked': 'ch',
493-
'selected': 's'
463+
var varNames = {
464+
'addAttribute': 'addAttribute',
465+
'modifyAttribute': 'modifyAttribute',
466+
'removeAttribute': 'removeAttribute',
467+
'modifyTextElement': 'modifyTextElement',
468+
'relocateGroup': 'relocateGroup',
469+
'removeElement': 'removeElement',
470+
'addElement': 'addElement',
471+
'removeTextElement': 'removeTextElement',
472+
'addTextElement': 'addTextElement',
473+
'replaceElement': 'replaceElement',
474+
'modifyValue': 'modifyValue',
475+
'modifyChecked': 'modifyChecked',
476+
'modifySelected': 'modifySelected',
477+
'modifyComment': 'modifyComment',
478+
'action': 'action',
479+
'route': 'route',
480+
'oldValue': 'oldValue',
481+
'newValue': 'newValue',
482+
'element': 'element',
483+
'group': 'group',
484+
'from': 'from',
485+
'to': 'to',
486+
'name': 'name',
487+
'value': 'value',
488+
'data': 'data',
489+
'attributes': 'attributes',
490+
'nodeName': 'nodeName',
491+
'childNodes': 'childNodes',
492+
'checked': 'checked',
493+
'selected': 'selected'
494494
};
495+
496+
if (this.compress) {
497+
j = 0;
498+
this._const = {};
499+
for (i in varNames) {
500+
this._const[i] = j;
501+
j++;
502+
}
503+
} else {
504+
this._const = varNames;
505+
}
495506
};
496507

497508
diffDOM.Diff = Diff;
@@ -703,7 +714,6 @@
703714
}
704715
}
705716
}
706-
707717
return objNode;
708718
},
709719
objToNode: function(objNode, insideSvg) {

0 commit comments

Comments
 (0)