From b0bea8d363c03e64a67eb18c4e8702c69ecb72cc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Sun, 8 Dec 2013 00:19:33 +0100 Subject: [PATCH] smartxml: pass transformation instance to impl & undo when needed impl needs this to be able to store state that may be needed in undo implementation --- src/smartxml/transformations.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/smartxml/transformations.js b/src/smartxml/transformations.js index 5e461ee..9aea150 100644 --- a/src/smartxml/transformations.js +++ b/src/smartxml/transformations.js @@ -95,13 +95,14 @@ toret.createGenericTransformation = function(desc, name) { this.changeRootPath = changeRoot.getPath(); } //var toret = desc.impl.call(this.context, this.args); // a argumenty do metody? - var toret = desc.impl.apply(this.context, this.args); + var argsToPass = desc.undo ? [this].concat(this.args) : this.args; + var toret = desc.impl.apply(this.context, argsToPass); this.hasRun = true; return toret; }, undo: function() { if(desc.undo) { - desc.undo.call(this.context); + desc.undo.call(this.context, this); } else { this.document.getNodeByPath(this.changeRootPath).replaceWith(this.snapshot); } -- 2.20.1