wlxml: helper functions related to context root
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Fri, 8 Aug 2014 08:42:31 +0000 (10:42 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 14 Aug 2014 14:26:15 +0000 (16:26 +0200)
src/wlxml/wlxml.js

index 40ab196..ef70d3d 100644 (file)
@@ -44,6 +44,19 @@ var WLXMLDocumentNodeMethods =  {
             }
         }.bind(this));
         return toret;
             }
         }.bind(this));
         return toret;
+    },
+    getContextRoot: function() {
+        var contextRoot;
+        [this].concat(this.parents()).some(function(n) {
+            if(n.isContextRoot()) {
+                contextRoot = n;
+                return true;
+            }
+        });
+        return contextRoot;
+    },
+    hasSameContextRoot: function(other) {
+        return this.getContextRoot().sameNode(other.getContextRoot());
     }
 };
 
     }
 };
 
@@ -183,7 +196,6 @@ var WLXMLDocumentNode = function() {
 };
 WLXMLDocumentNode.prototype = Object.create(smartxml.DocumentNode.prototype);
 
 };
 WLXMLDocumentNode.prototype = Object.create(smartxml.DocumentNode.prototype);
 
-
 var WLXMLTextNode = function() {
     smartxml.TextNode.apply(this, arguments);
 };
 var WLXMLTextNode = function() {
     smartxml.TextNode.apply(this, arguments);
 };