X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/21cd91531dd9c6e88d00da03f6b2f3ad88fb0da0..1f6c4e3196778b8d0e91988c8c56966f9bb2ef8f:/src/smartxml/transformations.js?ds=sidebyside diff --git a/src/smartxml/transformations.js b/src/smartxml/transformations.js index 25c0ec1..3f4b65f 100644 --- a/src/smartxml/transformations.js +++ b/src/smartxml/transformations.js @@ -90,7 +90,17 @@ toret.createGenericTransformation = function(desc, name) { run: function(options) { var changeRoot; if(!desc.undo && options.beUndoable) { - changeRoot = desc.getChangeRoot ? desc.getChangeRoot.call(this) : this.document.root; + if(desc.getChangeRoot) { + changeRoot = desc.getChangeRoot.call(this); + if(!changeRoot) { + throw new Error( + 'Transformation {name} returned invalid change root value' + .replace('{name}', name) + ); + } + } else { + changeRoot = this.document.root; + } this.snapshot = changeRoot.clone(); this.changeRootPath = changeRoot.getPath(); }