smartxml: only send change event when node is currently in a document tree
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 19 Nov 2013 09:29:09 +0000 (10:29 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 19 Nov 2013 09:29:09 +0000 (10:29 +0100)
src/smartxml/smartxml.js

index 6e754de..0dd7082 100644 (file)
@@ -84,7 +84,9 @@ $.extend(DocumentNode.prototype, {
 
     triggerChangeEvent: function(type, metaData) {
         var event = new events.ChangeEvent(type, $.extend({node: this}, metaData || {}));
-        this.document.trigger('change', event);
+        if(type === 'nodeDetached' || this.document.containsNode(event.meta.node)) {
+            this.document.trigger('change', event);
+        }
     },
     
     getNodeInsertion: function(node) {