linting
[fnpeditor.git] / src / smartxml / smartxml.js
index 8eeca1a..2d0e09f 100644 (file)
@@ -9,22 +9,34 @@ var TEXT_NODE = Node.TEXT_NODE, ELEMENT_NODE = Node.ELEMENT_NODE;
 
 var parseXML = function(xml) {
     return $(xml)[0];
-}
+};
 
 var Document = function(nativeNode) {
     var $document = $(nativeNode);
 
 
-    Object.defineProperty(this, 'root', {get: function() { return new ElementNode($document[0])}}); 
-}
+    Object.defineProperty(this, 'root', {get: function() { return new ElementNode($document[0]);}});
+};
 
 
-var ElementNode = function(nativeNode) {
+var DocumentNode = function(nativeNode) {
     this.nativeNode = nativeNode;
     this._$ = $(nativeNode);
 };
 
-$.extend(ElementNode.prototype, {
+$.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, DocumentNode.prototype, {
     nodeType: Node.ELEMENT_NODE,
 
     getTagName: function() {
@@ -50,19 +62,10 @@ $.extend(ElementNode.prototype, {
         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());
     },
@@ -114,17 +117,12 @@ $.extend(ElementNode.prototype, {
 });
 
 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;
     },
@@ -136,7 +134,7 @@ $.extend(TextNode.prototype, {
     prependText: function(text) {
         this.nativeNode.data = text + this.nativeNode.data;
     }
-})
+});
 
 
 return {