From 6b6d2a8c7dfde855e81a9b02ca38f69d6dfb9440 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Sun, 8 Dec 2013 13:40:58 +0100 Subject: [PATCH 1/1] smartxml: throw exception on transformation returning invalid change root --- src/smartxml/transformations.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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(); } -- 2.20.1