From: Aleksander Ɓukasz Date: Fri, 8 Aug 2014 08:42:31 +0000 (+0200) Subject: wlxml: helper functions related to context root X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/e10030e66aab8b55dab8b8ba507a9140243129fa?hp=248bc3fefa3eed44a6ffed7374bea9310962fb88 wlxml: helper functions related to context root --- 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); };