},
detach: function() {
+ var parent = this.parent();
this._$.detach();
+ this.triggerChangeEvent('nodeDetached', {parent: parent});
return this;
},
},
parent: function() {
- return this.nativeNode.parentNode ? this.document.createElementNode(this.nativeNode.parentNode) : null;
+ var parentNode = this.nativeNode.parentNode;
+ if(parentNode && parentNode.nodeType === Node.ELEMENT_NODE) {
+ return this.document.createElementNode(parentNode);
+ }
+ return null;
},
after: function(node) {
insertion.insertsNew = true;
}
return insertion;
+ },
+
+ getIndex: function() {
+ return this.parent().indexOf(this);
}
});
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) {