+ this.nativeNode = nativeNode;
+ this._$ = $(nativeNode);
+};
+
+$.extend(ElementNode.prototype, {
+ nodeType: Node.ELEMENT_NODE,
+
+ getTagName: function() {
+ return this.nativeNode.tagName.toLowerCase();
+ },
+
+ append: function(documentNode) {
+ this._$.append(documentNode.nativeNode);
+ },
+
+ before: function(node) {
+ this._$.before(node.nativeNode);
+ },
+
+ contents: function() {
+ var toret = [];
+ this._$.contents().each(function() {
+ if(this.nodeType === Node.ELEMENT_NODE)
+ toret.push(new ElementNode(this));
+ else if(this.nodeType === Node.TEXT_NODE)
+ toret.push(new TextNode(this));
+ });
+ return toret;
+ },
+
+
+ sameNode: function(otherNode) {
+ return this.nativeNode === otherNode.nativeNode;
+ },
+
+ indexOf: function(node) {
+ return this._$.contents().index(node._$);
+ },
+
+ detach: function() {
+ this._$.detach();
+ },
+
+ parent: function() {
+ return new ElementNode(this._$.parent());
+ },
+
+ unwrapContent: function() {
+ var parent = this.parent();
+ if(!parent)
+ return;
+
+ var parentContents = parent.contents(),
+ myContents = this.contents(),
+ myIdx = parent.indexOf(this);
+
+ if(myContents.length === 0)
+ return this.detach();