From: Aleksander Ɓukasz Date: Fri, 29 Nov 2013 10:53:49 +0000 (+0100) Subject: Always create new element on nodeAdded event X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/d18c7b69cbc94bec9a75a4c1e0671e65597b5b24?ds=inline Always create new element on nodeAdded event Checking for existence on canvas should be performed only if handling nodeMoved event. --- diff --git a/src/editor/modules/documentCanvas/canvas/wlxmlListener.js b/src/editor/modules/documentCanvas/canvas/wlxmlListener.js index c5deabf..ce9de6d 100644 --- a/src/editor/modules/documentCanvas/canvas/wlxmlListener.js +++ b/src/editor/modules/documentCanvas/canvas/wlxmlListener.js @@ -40,7 +40,7 @@ var handlers = { var canvasNode = utils.findCanvasElement(event.meta.node); canvasNode.setWlxmlTag(event.meta.newTagName); }, - nodeAdded: function(event) { + nodeAdded: function(event, checkForExistence) { if(event.meta.node.isRoot()) { this.canvas.reloadRoot(); return; @@ -57,11 +57,11 @@ var handlers = { referenceAction = 'after'; } - actionArg = utils.findCanvasElement(event.meta.node) || event.meta.node; + actionArg = (checkForExistence && utils.findCanvasElement(event.meta.node)) || event.meta.node; referenceElement[referenceAction](actionArg); }, nodeMoved: function(event) { - return handlers.nodeAdded(event); + return handlers.nodeAdded(event, true); }, nodeDetached: function(event) { var canvasNode = utils.findCanvasElementInParent(event.meta.node, event.meta.parent);