}
-var ElementNode = function(nativeNode) {
+var DocumentNode = function(nativeNode) {
this.nativeNode = nativeNode;
this._$ = $(nativeNode);
+}
+
+$.extend(DocumentNode.prototype, {
+ detach: function() { this._$.detach(); },
+
+ sameNode: function(otherNode) {
+ return this.nativeNode === otherNode.nativeNode;
+ }
+})
+
+var ElementNode = function(nativeNode) {
+ DocumentNode.apply(this, arguments);
};
-$.extend(ElementNode.prototype, {
+$.extend(ElementNode.prototype, DocumentNode.prototype, {
nodeType: Node.ELEMENT_NODE,
getTagName: function() {
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());
},
});
var TextNode = function(nativeNode) {
- this.nativeNode = nativeNode;
- this._$ = $(nativeNode);
+ DocumentNode.apply(this, arguments);
}
-$.extend(TextNode.prototype, {
+$.extend(TextNode.prototype, DocumentNode.prototype, {
nodeType: Node.TEXT_NODE,
- detach: function() {
- this._$.detach();
- },
-
getText: function() {
return this.nativeNode.data;
},