}),
wrapWith: function(node) {
- node = node instanceof ElementNode ? node : this.document.createElementNode(node);
-
+ var insertion = this.getNodeInsertion(node);
if(this.parent()) {
- this.before(node);
+ this.before(insertion.ofNode);
}
- node.append(this);
- return node;
+ insertion.ofNode.append(this);
+ return insertion.ofNode;
},
/**
},
getIndex: function() {
+ if(this.isRoot()) {
+ return 0;
+ }
return this.parent().indexOf(this);
}
});
myContents = this.contents(),
myIdx = parent.indexOf(this);
+
if(myContents.length === 0) {
return this.detach();
}