From e10030e66aab8b55dab8b8ba507a9140243129fa Mon Sep 17 00:00:00 2001 From: =?utf8?q?Aleksander=20=C5=81ukasz?= Date: Fri, 8 Aug 2014 10:42:31 +0200 Subject: [PATCH] wlxml: helper functions related to context root --- src/wlxml/wlxml.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/wlxml/wlxml.js b/src/wlxml/wlxml.js index 40ab196..ef70d3d 100644 --- a/src/wlxml/wlxml.js +++ b/src/wlxml/wlxml.js @@ -44,6 +44,19 @@ var WLXMLDocumentNodeMethods = { } }.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); - var WLXMLTextNode = function() { smartxml.TextNode.apply(this, arguments); }; -- 2.20.1