Refactor
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 26 Sep 2013 12:23:08 +0000 (14:23 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 9 Oct 2013 14:56:54 +0000 (16:56 +0200)
src/smartxml/smartxml.js

index 4bb5afe..0c76cd2 100644 (file)
@@ -18,33 +18,34 @@ var Document = function(nativeNode) {
 
 
 var ElementNode = function(nativeNode) {
-    var myNode = nativeNode,
-        $myNode = $(nativeNode);
-
-    this._$myNode = $myNode;
-    this._myNode= myNode;
+    this.nativeNode = nativeNode;
+    this._$ = $(nativeNode);
+};
 
-    this.getTagName = function() {
-        return myNode.tagName.toLowerCase();
-    };
+$.extend(ElementNode.prototype, {
+    getTagName: function() {
+        return this.nativeNode.tagName.toLowerCase();
+    },
 
-    this.append = function(documentNode) {
-        this._$myNode.append(documentNode._$myNode);
-    };
+    append: function(documentNode) {
+        this._$.append(documentNode.nativeNode);
+    },
 
-    this.contents = function() {
+    contents: function() {
         var toret = [];
-        this._$myNode.contents().each(function() {
+        this._$.contents().each(function() {
             if(this.nodeType === Node.ELEMENT_NODE)
                 toret.push(new ElementNode(this));
         });
         return toret;
-    };
+    },
+
 
-    this.sameNode = function(otherNode) {
-        return this._myNode === otherNode._myNode;
+    sameNode: function(otherNode) {
+        return this.nativeNode === otherNode.nativeNode;
     }
-};
+
+});
 
 return {
     documentFromXML: function(xml) {