smartxml: append/prepend shortcuts for text nodes
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 23 Jan 2014 13:42:34 +0000 (14:42 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 23 Jan 2014 13:42:34 +0000 (14:42 +0100)
src/smartxml/core.js

index 4297c1a..65b7852 100644 (file)
@@ -240,6 +240,21 @@ var textNodeTransformations = {
         }
     }),
 
+    append: function(node) {
+        if(node.nodeType === Node.TEXT_NODE) {
+            this.appendText(node.getText());
+            node.detach();
+            return this;
+        }
+    },
+    prepend: function(node) {
+        if(node.nodeType === Node.TEXT_NODE) {
+            this.prependText(node.getText());
+            node.detach();
+            return this;
+        }
+    },
+
     appendText: function(text) {
         this.nativeNode.data = this.nativeNode.data + text;
         this.triggerTextChangeEvent();