From 24f79c15db362b3646ce15d0dc6d9c703040e892 Mon Sep 17 00:00:00 2001
From: =?utf8?q?Aleksander=20=C5=81ukasz?=
 <aleksander.lukasz@nowoczesnapolska.org.pl>
Date: Fri, 25 Oct 2013 15:32:40 +0200
Subject: [PATCH] smartxml: fixing text node creation

---
 src/smartxml/smartxml.js | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/smartxml/smartxml.js b/src/smartxml/smartxml.js
index b4036d3..cbb2ba8 100644
--- a/src/smartxml/smartxml.js
+++ b/src/smartxml/smartxml.js
@@ -319,7 +319,13 @@ $.extend(Document.prototype, Backbone.Events, {
                 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) {
-- 
2.20.1