smartxml: fixing text node creation
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Fri, 25 Oct 2013 13:32:40 +0000 (15:32 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Fri, 25 Oct 2013 13:40:26 +0000 (15:40 +0200)
src/smartxml/smartxml.js

index b4036d3..cbb2ba8 100644 (file)
@@ -319,7 +319,13 @@ $.extend(Document.prototype, Backbone.Events, {
                 from = node[0];
             }
         }
                 from = node[0];
             }
         }
-        return new this.ElementNodeFactory(from, this);
+        var Factory;
+        if(from.nodeType === Node.TEXT_NODE) {
+            Factory = this.TextNodeFactory;
+        } else if(from.nodeType === Node.ELEMENT_NODE) {
+            Factory = this.ElementNodeFactory;
+        }
+        return new Factory(from, this);
     },
 
     createTextNode: function(nativeNode) {
     },
 
     createTextNode: function(nativeNode) {