history.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. /**
  2. * Package: svedit.history
  3. *
  4. * Licensed under the Apache License, Version 2
  5. *
  6. * Copyright(c) 2010 Jeff Schiller
  7. */
  8. // Dependencies:
  9. // 1) jQuery
  10. // 2) svgtransformlist.js
  11. // 3) svgutils.js
  12. var svgedit = svgedit || {};
  13. (function() {
  14. if (!svgedit.history) {
  15. svgedit.history = {};
  16. }
  17. // Group: Undo/Redo history management
  18. svgedit.history.HistoryEventTypes = {
  19. BEFORE_APPLY: 'before_apply',
  20. AFTER_APPLY: 'after_apply',
  21. BEFORE_UNAPPLY: 'before_unapply',
  22. AFTER_UNAPPLY: 'after_unapply'
  23. };
  24. var removedElements = {};
  25. /**
  26. * Interface: svgedit.history.HistoryCommand
  27. * An interface that all command objects must implement.
  28. *
  29. * interface svgedit.history.HistoryCommand {
  30. * void apply(svgedit.history.HistoryEventHandler);
  31. * void unapply(svgedit.history.HistoryEventHandler);
  32. * Element[] elements();
  33. * String getText();
  34. *
  35. * static String type();
  36. * }
  37. *
  38. * Interface: svgedit.history.HistoryEventHandler
  39. * An interface for objects that will handle history events.
  40. *
  41. * interface svgedit.history.HistoryEventHandler {
  42. * void handleHistoryEvent(eventType, command);
  43. * }
  44. *
  45. * eventType is a string conforming to one of the HistoryEvent types.
  46. * command is an object fulfilling the HistoryCommand interface.
  47. */
  48. // Class: svgedit.history.MoveElementCommand
  49. // implements svgedit.history.HistoryCommand
  50. // History command for an element that had its DOM position changed
  51. //
  52. // Parameters:
  53. // elem - The DOM element that was moved
  54. // oldNextSibling - The element's next sibling before it was moved
  55. // oldParent - The element's parent before it was moved
  56. // text - An optional string visible to user related to this change
  57. svgedit.history.MoveElementCommand = function(elem, oldNextSibling, oldParent, text) {
  58. this.elem = elem;
  59. this.text = text ? ("Move " + elem.tagName + " to " + text) : ("Move " + elem.tagName);
  60. this.oldNextSibling = oldNextSibling;
  61. this.oldParent = oldParent;
  62. this.newNextSibling = elem.nextSibling;
  63. this.newParent = elem.parentNode;
  64. };
  65. svgedit.history.MoveElementCommand.type = function() { return 'svgedit.history.MoveElementCommand'; }
  66. svgedit.history.MoveElementCommand.prototype.type = svgedit.history.MoveElementCommand.type;
  67. // Function: svgedit.history.MoveElementCommand.getText
  68. svgedit.history.MoveElementCommand.prototype.getText = function() {
  69. return this.text;
  70. };
  71. // Function: svgedit.history.MoveElementCommand.apply
  72. // Re-positions the element
  73. svgedit.history.MoveElementCommand.prototype.apply = function(handler) {
  74. // TODO(codedread): Refactor this common event code into a base HistoryCommand class.
  75. if (handler) {
  76. handler.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY, this);
  77. }
  78. this.elem = this.newParent.insertBefore(this.elem, this.newNextSibling);
  79. if (handler) {
  80. handler.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY, this);
  81. }
  82. };
  83. // Function: svgedit.history.MoveElementCommand.unapply
  84. // Positions the element back to its original location
  85. svgedit.history.MoveElementCommand.prototype.unapply = function(handler) {
  86. if (handler) {
  87. handler.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY, this);
  88. }
  89. this.elem = this.oldParent.insertBefore(this.elem, this.oldNextSibling);
  90. if (handler) {
  91. handler.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY, this);
  92. }
  93. };
  94. // Function: svgedit.history.MoveElementCommand.elements
  95. // Returns array with element associated with this command
  96. svgedit.history.MoveElementCommand.prototype.elements = function() {
  97. return [this.elem];
  98. };
  99. // Class: svgedit.history.InsertElementCommand
  100. // implements svgedit.history.HistoryCommand
  101. // History command for an element that was added to the DOM
  102. //
  103. // Parameters:
  104. // elem - The newly added DOM element
  105. // text - An optional string visible to user related to this change
  106. svgedit.history.InsertElementCommand = function(elem, text) {
  107. this.elem = elem;
  108. this.text = text || ("Create " + elem.tagName);
  109. this.parent = elem.parentNode;
  110. this.nextSibling = this.elem.nextSibling;
  111. };
  112. svgedit.history.InsertElementCommand.type = function() { return 'svgedit.history.InsertElementCommand'; }
  113. svgedit.history.InsertElementCommand.prototype.type = svgedit.history.InsertElementCommand.type;
  114. // Function: svgedit.history.InsertElementCommand.getText
  115. svgedit.history.InsertElementCommand.prototype.getText = function() {
  116. return this.text;
  117. };
  118. // Function: svgedit.history.InsertElementCommand.apply
  119. // Re-Inserts the new element
  120. svgedit.history.InsertElementCommand.prototype.apply = function(handler) {
  121. if (handler) {
  122. handler.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY, this);
  123. }
  124. this.elem = this.parent.insertBefore(this.elem, this.nextSibling);
  125. if (handler) {
  126. handler.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY, this);
  127. }
  128. };
  129. // Function: svgedit.history.InsertElementCommand.unapply
  130. // Removes the element
  131. svgedit.history.InsertElementCommand.prototype.unapply = function(handler) {
  132. if (handler) {
  133. handler.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY, this);
  134. }
  135. this.parent = this.elem.parentNode;
  136. this.elem = this.elem.parentNode.removeChild(this.elem);
  137. if (handler) {
  138. handler.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY, this);
  139. }
  140. };
  141. // Function: svgedit.history.InsertElementCommand.elements
  142. // Returns array with element associated with this command
  143. svgedit.history.InsertElementCommand.prototype.elements = function() {
  144. return [this.elem];
  145. };
  146. // Class: svgedit.history.RemoveElementCommand
  147. // implements svgedit.history.HistoryCommand
  148. // History command for an element removed from the DOM
  149. //
  150. // Parameters:
  151. // elem - The removed DOM element
  152. // oldNextSibling - the DOM element's nextSibling when it was in the DOM
  153. // oldParent - The DOM element's parent
  154. // text - An optional string visible to user related to this change
  155. svgedit.history.RemoveElementCommand = function(elem, oldNextSibling, oldParent, text) {
  156. this.elem = elem;
  157. this.text = text || ("Delete " + elem.tagName);
  158. this.nextSibling = oldNextSibling;
  159. this.parent = oldParent;
  160. // special hack for webkit: remove this element's entry in the svgTransformLists map
  161. svgedit.transformlist.removeElementFromListMap(elem);
  162. };
  163. svgedit.history.RemoveElementCommand.type = function() { return 'svgedit.history.RemoveElementCommand'; }
  164. svgedit.history.RemoveElementCommand.prototype.type = svgedit.history.RemoveElementCommand.type;
  165. // Function: svgedit.history.RemoveElementCommand.getText
  166. svgedit.history.RemoveElementCommand.prototype.getText = function() {
  167. return this.text;
  168. };
  169. // Function: RemoveElementCommand.apply
  170. // Re-removes the new element
  171. svgedit.history.RemoveElementCommand.prototype.apply = function(handler) {
  172. if (handler) {
  173. handler.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY, this);
  174. }
  175. svgedit.transformlist.removeElementFromListMap(this.elem);
  176. this.parent = this.elem.parentNode;
  177. this.elem = this.parent.removeChild(this.elem);
  178. if (handler) {
  179. handler.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY, this);
  180. }
  181. };
  182. // Function: RemoveElementCommand.unapply
  183. // Re-adds the new element
  184. svgedit.history.RemoveElementCommand.prototype.unapply = function(handler) {
  185. if (handler) {
  186. handler.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY, this);
  187. }
  188. svgedit.transformlist.removeElementFromListMap(this.elem);
  189. if(this.nextSibling == null) {
  190. if(window.console) console.log('Error: reference element was lost');
  191. }
  192. this.parent.insertBefore(this.elem, this.nextSibling);
  193. if (handler) {
  194. handler.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY, this);
  195. }
  196. };
  197. // Function: RemoveElementCommand.elements
  198. // Returns array with element associated with this command
  199. svgedit.history.RemoveElementCommand.prototype.elements = function() {
  200. return [this.elem];
  201. };
  202. // Class: svgedit.history.ChangeElementCommand
  203. // implements svgedit.history.HistoryCommand
  204. // History command to make a change to an element.
  205. // Usually an attribute change, but can also be textcontent.
  206. //
  207. // Parameters:
  208. // elem - The DOM element that was changed
  209. // attrs - An object with the attributes to be changed and the values they had *before* the change
  210. // text - An optional string visible to user related to this change
  211. svgedit.history.ChangeElementCommand = function(elem, attrs, text) {
  212. this.elem = elem;
  213. this.text = text ? ("Change " + elem.tagName + " " + text) : ("Change " + elem.tagName);
  214. this.newValues = {};
  215. this.oldValues = attrs;
  216. for (var attr in attrs) {
  217. if (attr == "#text") this.newValues[attr] = elem.textContent;
  218. else if (attr == "#href") this.newValues[attr] = svgedit.utilities.getHref(elem);
  219. else this.newValues[attr] = elem.getAttribute(attr);
  220. }
  221. };
  222. svgedit.history.ChangeElementCommand.type = function() { return 'svgedit.history.ChangeElementCommand'; }
  223. svgedit.history.ChangeElementCommand.prototype.type = svgedit.history.ChangeElementCommand.type;
  224. // Function: svgedit.history.ChangeElementCommand.getText
  225. svgedit.history.ChangeElementCommand.prototype.getText = function() {
  226. return this.text;
  227. };
  228. // Function: svgedit.history.ChangeElementCommand.apply
  229. // Performs the stored change action
  230. svgedit.history.ChangeElementCommand.prototype.apply = function(handler) {
  231. if (handler) {
  232. handler.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY, this);
  233. }
  234. var bChangedTransform = false;
  235. for(var attr in this.newValues ) {
  236. if (this.newValues[attr]) {
  237. if (attr == "#text") this.elem.textContent = this.newValues[attr];
  238. else if (attr == "#href") svgedit.utilities.setHref(this.elem, this.newValues[attr])
  239. else this.elem.setAttribute(attr, this.newValues[attr]);
  240. }
  241. else {
  242. if (attr == "#text") {
  243. this.elem.textContent = "";
  244. }
  245. else {
  246. this.elem.setAttribute(attr, "");
  247. this.elem.removeAttribute(attr);
  248. }
  249. }
  250. if (attr == "transform") { bChangedTransform = true; }
  251. }
  252. // relocate rotational transform, if necessary
  253. if(!bChangedTransform) {
  254. var angle = svgedit.utilities.getRotationAngle(this.elem);
  255. if (angle) {
  256. var bbox = elem.getBBox();
  257. var cx = bbox.x + bbox.width/2,
  258. cy = bbox.y + bbox.height/2;
  259. var rotate = ["rotate(", angle, " ", cx, ",", cy, ")"].join('');
  260. if (rotate != elem.getAttribute("transform")) {
  261. elem.setAttribute("transform", rotate);
  262. }
  263. }
  264. }
  265. if (handler) {
  266. handler.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY, this);
  267. }
  268. return true;
  269. };
  270. // Function: svgedit.history.ChangeElementCommand.unapply
  271. // Reverses the stored change action
  272. svgedit.history.ChangeElementCommand.prototype.unapply = function(handler) {
  273. if (handler) {
  274. handler.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY, this);
  275. }
  276. var bChangedTransform = false;
  277. for(var attr in this.oldValues ) {
  278. if (this.oldValues[attr]) {
  279. if (attr == "#text") this.elem.textContent = this.oldValues[attr];
  280. else if (attr == "#href") svgedit.utilities.setHref(this.elem, this.oldValues[attr]);
  281. else this.elem.setAttribute(attr, this.oldValues[attr]);
  282. }
  283. else {
  284. if (attr == "#text") {
  285. this.elem.textContent = "";
  286. }
  287. else this.elem.removeAttribute(attr);
  288. }
  289. if (attr == "transform") { bChangedTransform = true; }
  290. }
  291. // relocate rotational transform, if necessary
  292. if(!bChangedTransform) {
  293. var angle = svgedit.utilities.getRotationAngle(this.elem);
  294. if (angle) {
  295. var bbox = elem.getBBox();
  296. var cx = bbox.x + bbox.width/2,
  297. cy = bbox.y + bbox.height/2;
  298. var rotate = ["rotate(", angle, " ", cx, ",", cy, ")"].join('');
  299. if (rotate != elem.getAttribute("transform")) {
  300. elem.setAttribute("transform", rotate);
  301. }
  302. }
  303. }
  304. // Remove transformlist to prevent confusion that causes bugs like 575.
  305. svgedit.transformlist.removeElementFromListMap(this.elem);
  306. if (handler) {
  307. handler.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY, this);
  308. }
  309. return true;
  310. };
  311. // Function: ChangeElementCommand.elements
  312. // Returns array with element associated with this command
  313. svgedit.history.ChangeElementCommand.prototype.elements = function() {
  314. return [this.elem];
  315. };
  316. // TODO: create a 'typing' command object that tracks changes in text
  317. // if a new Typing command is created and the top command on the stack is also a Typing
  318. // and they both affect the same element, then collapse the two commands into one
  319. // Class: svgedit.history.BatchCommand
  320. // implements svgedit.history.HistoryCommand
  321. // History command that can contain/execute multiple other commands
  322. //
  323. // Parameters:
  324. // text - An optional string visible to user related to this change
  325. svgedit.history.BatchCommand = function(text) {
  326. this.text = text || "Batch Command";
  327. this.stack = [];
  328. };
  329. svgedit.history.BatchCommand.type = function() { return 'svgedit.history.BatchCommand'; }
  330. svgedit.history.BatchCommand.prototype.type = svgedit.history.BatchCommand.type;
  331. // Function: svgedit.history.BatchCommand.getText
  332. svgedit.history.BatchCommand.prototype.getText = function() {
  333. return this.text;
  334. };
  335. // Function: svgedit.history.BatchCommand.apply
  336. // Runs "apply" on all subcommands
  337. svgedit.history.BatchCommand.prototype.apply = function(handler) {
  338. if (handler) {
  339. handler.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_APPLY, this);
  340. }
  341. var len = this.stack.length;
  342. for (var i = 0; i < len; ++i) {
  343. this.stack[i].apply(handler);
  344. }
  345. if (handler) {
  346. handler.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_APPLY, this);
  347. }
  348. };
  349. // Function: svgedit.history.BatchCommand.unapply
  350. // Runs "unapply" on all subcommands
  351. svgedit.history.BatchCommand.prototype.unapply = function(handler) {
  352. if (handler) {
  353. handler.handleHistoryEvent(svgedit.history.HistoryEventTypes.BEFORE_UNAPPLY, this);
  354. }
  355. for (var i = this.stack.length-1; i >= 0; i--) {
  356. this.stack[i].unapply(handler);
  357. }
  358. if (handler) {
  359. handler.handleHistoryEvent(svgedit.history.HistoryEventTypes.AFTER_UNAPPLY, this);
  360. }
  361. };
  362. // Function: svgedit.history.BatchCommand.elements
  363. // Iterate through all our subcommands and returns all the elements we are changing
  364. svgedit.history.BatchCommand.prototype.elements = function() {
  365. var elems = [];
  366. var cmd = this.stack.length;
  367. while (cmd--) {
  368. var thisElems = this.stack[cmd].elements();
  369. var elem = thisElems.length;
  370. while (elem--) {
  371. if (elems.indexOf(thisElems[elem]) == -1) elems.push(thisElems[elem]);
  372. }
  373. }
  374. return elems;
  375. };
  376. // Function: svgedit.history.BatchCommand.addSubCommand
  377. // Adds a given command to the history stack
  378. //
  379. // Parameters:
  380. // cmd - The undo command object to add
  381. svgedit.history.BatchCommand.prototype.addSubCommand = function(cmd) {
  382. this.stack.push(cmd);
  383. };
  384. // Function: svgedit.history.BatchCommand.isEmpty
  385. // Returns a boolean indicating whether or not the batch command is empty
  386. svgedit.history.BatchCommand.prototype.isEmpty = function() {
  387. return this.stack.length == 0;
  388. };
  389. // Class: svgedit.history.UndoManager
  390. // Parameters:
  391. // historyEventHandler - an object that conforms to the HistoryEventHandler interface
  392. // (see above)
  393. svgedit.history.UndoManager = function(historyEventHandler) {
  394. this.handler_ = historyEventHandler || null;
  395. this.undoStackPointer = 0;
  396. this.undoStack = [];
  397. // this is the stack that stores the original values, the elements and
  398. // the attribute name for begin/finish
  399. this.undoChangeStackPointer = -1;
  400. this.undoableChangeStack = [];
  401. };
  402. // Function: svgedit.history.UndoManager.resetUndoStack
  403. // Resets the undo stack, effectively clearing the undo/redo history
  404. svgedit.history.UndoManager.prototype.resetUndoStack = function() {
  405. this.undoStack = [];
  406. this.undoStackPointer = 0;
  407. };
  408. // Function: svgedit.history.UndoManager.getUndoStackSize
  409. // Returns:
  410. // Integer with the current size of the undo history stack
  411. svgedit.history.UndoManager.prototype.getUndoStackSize = function() {
  412. return this.undoStackPointer;
  413. };
  414. // Function: svgedit.history.UndoManager.getRedoStackSize
  415. // Returns:
  416. // Integer with the current size of the redo history stack
  417. svgedit.history.UndoManager.prototype.getRedoStackSize = function() {
  418. return this.undoStack.length - this.undoStackPointer;
  419. };
  420. // Function: svgedit.history.UndoManager.getNextUndoCommandText
  421. // Returns:
  422. // String associated with the next undo command
  423. svgedit.history.UndoManager.prototype.getNextUndoCommandText = function() {
  424. return this.undoStackPointer > 0 ? this.undoStack[this.undoStackPointer-1].getText() : "";
  425. };
  426. // Function: svgedit.history.UndoManager.getNextRedoCommandText
  427. // Returns:
  428. // String associated with the next redo command
  429. svgedit.history.UndoManager.prototype.getNextRedoCommandText = function() {
  430. return this.undoStackPointer < this.undoStack.length ? this.undoStack[this.undoStackPointer].getText() : "";
  431. };
  432. // Function: svgedit.history.UndoManager.undo
  433. // Performs an undo step
  434. svgedit.history.UndoManager.prototype.undo = function() {
  435. if (this.undoStackPointer > 0) {
  436. var cmd = this.undoStack[--this.undoStackPointer];
  437. cmd.unapply(this.handler_);
  438. }
  439. };
  440. // Function: svgedit.history.UndoManager.redo
  441. // Performs a redo step
  442. svgedit.history.UndoManager.prototype.redo = function() {
  443. if (this.undoStackPointer < this.undoStack.length && this.undoStack.length > 0) {
  444. var cmd = this.undoStack[this.undoStackPointer++];
  445. cmd.apply(this.handler_);
  446. }
  447. };
  448. // Function: svgedit.history.UndoManager.addCommandToHistory
  449. // Adds a command object to the undo history stack
  450. //
  451. // Parameters:
  452. // cmd - The command object to add
  453. svgedit.history.UndoManager.prototype.addCommandToHistory = function(cmd) {
  454. // FIXME: we MUST compress consecutive text changes to the same element
  455. // (right now each keystroke is saved as a separate command that includes the
  456. // entire text contents of the text element)
  457. // TODO: consider limiting the history that we store here (need to do some slicing)
  458. // if our stack pointer is not at the end, then we have to remove
  459. // all commands after the pointer and insert the new command
  460. if (this.undoStackPointer < this.undoStack.length && this.undoStack.length > 0) {
  461. this.undoStack = this.undoStack.splice(0, this.undoStackPointer);
  462. }
  463. this.undoStack.push(cmd);
  464. this.undoStackPointer = this.undoStack.length;
  465. };
  466. // Function: svgedit.history.UndoManager.beginUndoableChange
  467. // This function tells the canvas to remember the old values of the
  468. // attrName attribute for each element sent in. The elements and values
  469. // are stored on a stack, so the next call to finishUndoableChange() will
  470. // pop the elements and old values off the stack, gets the current values
  471. // from the DOM and uses all of these to construct the undo-able command.
  472. //
  473. // Parameters:
  474. // attrName - The name of the attribute being changed
  475. // elems - Array of DOM elements being changed
  476. svgedit.history.UndoManager.prototype.beginUndoableChange = function(attrName, elems) {
  477. var p = ++this.undoChangeStackPointer;
  478. var i = elems.length;
  479. var oldValues = new Array(i), elements = new Array(i);
  480. while (i--) {
  481. var elem = elems[i];
  482. if (elem == null) continue;
  483. elements[i] = elem;
  484. oldValues[i] = elem.getAttribute(attrName);
  485. }
  486. this.undoableChangeStack[p] = {'attrName': attrName,
  487. 'oldValues': oldValues,
  488. 'elements': elements};
  489. };
  490. // Function: svgedit.history.UndoManager.finishUndoableChange
  491. // This function returns a BatchCommand object which summarizes the
  492. // change since beginUndoableChange was called. The command can then
  493. // be added to the command history
  494. //
  495. // Returns:
  496. // Batch command object with resulting changes
  497. svgedit.history.UndoManager.prototype.finishUndoableChange = function() {
  498. var p = this.undoChangeStackPointer--;
  499. var changeset = this.undoableChangeStack[p];
  500. var i = changeset['elements'].length;
  501. var attrName = changeset['attrName'];
  502. var batchCmd = new svgedit.history.BatchCommand("Change " + attrName);
  503. while (i--) {
  504. var elem = changeset['elements'][i];
  505. if (elem == null) continue;
  506. var changes = {};
  507. changes[attrName] = changeset['oldValues'][i];
  508. if (changes[attrName] != elem.getAttribute(attrName)) {
  509. batchCmd.addSubCommand(new svgedit.history.ChangeElementCommand(elem, changes, attrName));
  510. }
  511. }
  512. this.undoableChangeStack[p] = null;
  513. return batchCmd;
  514. };
  515. })();