smartxml: Fixing single text node unwrap
[fnpeditor.git] / src / smartxml / smartxml.js
index 40f3aad..b150cde 100644 (file)
@@ -100,6 +100,22 @@ $.extend(DocumentNode.prototype, {
         return node;
     },
 
+    /**
+    * Removes parent of a node if node has no siblings.
+    */
+    unwrap: function() {
+        if(this.isRoot()) {
+            return;
+        }
+        var parent = this.parent(),
+            grandParent;
+        if(parent.contents().length === 1) {
+            grandParent = parent.parent();
+            parent.unwrapContent();
+            return grandParent;
+        }
+    },
+
     triggerChangeEvent: function(type, metaData) {
         var event = new events.ChangeEvent(type, $.extend({node: this}, metaData || {}));
         if(type === 'nodeDetached' || this.document.containsNode(event.meta.node)) {
@@ -275,22 +291,6 @@ $.extend(ElementNode.prototype, {
         };
     },
 
-    /**
-    * Removes parent of a node if node has no siblings.
-    */
-    unwrap: function() {
-        if(this.isRoot()) {
-            return;
-        }
-        var parent = this.parent(),
-            grandParent;
-        if(parent.contents().length === 1) {
-            grandParent = parent.parent();
-            parent.unwrapContent();
-            return grandParent;
-        }
-    },
-
     wrapText: function(params) {
         return this.document._wrapText(_.extend({inside: this}, params));
     },