|
239 | 239 | var cloneObj = function(obj) { |
240 | 240 | // TODO: Do we really need to clone here? Is it not enough to just return the original object? |
241 | 241 | return JSON.parse(JSON.stringify(obj)); |
242 | | - //return obj; |
243 | 242 | }; |
244 | 243 |
|
245 | 244 | /** |
|
444 | 443 | postVirtualDiffApply: function() {}, |
445 | 444 | preDiffApply: function() {}, |
446 | 445 | postDiffApply: function() {}, |
447 | | - filterOuterDiff: null |
| 446 | + filterOuterDiff: null, |
| 447 | + compress: false // Whether to work with compressed diffs |
448 | 448 | }, |
449 | | - i; |
| 449 | + varNames, i, j; |
450 | 450 |
|
451 | 451 | if (typeof options === "undefined") { |
452 | 452 | options = {}; |
|
460 | 460 | } |
461 | 461 | } |
462 | 462 |
|
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' |
494 | 494 | }; |
| 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 | + } |
495 | 506 | }; |
496 | 507 |
|
497 | 508 | diffDOM.Diff = Diff; |
|
703 | 714 | } |
704 | 715 | } |
705 | 716 | } |
706 | | - |
707 | 717 | return objNode; |
708 | 718 | }, |
709 | 719 | objToNode: function(objNode, insideSvg) { |
|
0 commit comments