Always create new element on nodeAdded event
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Fri, 29 Nov 2013 10:53:49 +0000 (11:53 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 2 Dec 2013 13:50:54 +0000 (14:50 +0100)
Checking for existence on canvas should be performed only if
handling nodeMoved event.

src/editor/modules/documentCanvas/canvas/wlxmlListener.js

index c5deabf..ce9de6d 100644 (file)
@@ -40,7 +40,7 @@ var handlers = {
         var canvasNode = utils.findCanvasElement(event.meta.node);
         canvasNode.setWlxmlTag(event.meta.newTagName);
     },
         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;
         if(event.meta.node.isRoot()) {
             this.canvas.reloadRoot();
             return;
@@ -57,11 +57,11 @@ var handlers = {
             referenceAction = 'after';
         }
 
             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) {
         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);
     },
     nodeDetached: function(event) {
         var canvasNode = utils.findCanvasElementInParent(event.meta.node, event.meta.parent);