smartxml: refactoring
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 19 Nov 2013 15:45:28 +0000 (16:45 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 19 Nov 2013 15:45:28 +0000 (16:45 +0100)
src/smartxml/smartxml.js

index e484070..05583c5 100644 (file)
@@ -91,13 +91,12 @@ $.extend(DocumentNode.prototype, {
     }),
 
     wrapWith: function(node) {
     }),
 
     wrapWith: function(node) {
-        node = node instanceof ElementNode ? node : this.document.createElementNode(node);
-
+        var insertion = this.getNodeInsertion(node);
         if(this.parent()) {
         if(this.parent()) {
-            this.before(node);
+            this.before(insertion.ofNode);
         }
         }
-        node.append(this);
-        return node;
+        insertion.ofNode.append(this);
+        return insertion.ofNode;
     },
 
     /**
     },
 
     /**