-var isMetaAttribute = function(attrName) {
- return attrName.substr(0, 5) === 'meta-';
+
+var WLXMLDocumentNodeMethods = {
+ isInside: function(query) {
+ var parent = this.getParent(query);
+ return !!parent;
+ },
+ getParent: function(query) {
+ /* globals Node */
+ var me = this.nodeType === Node.ELEMENT_NODE ? [this] : [],
+ toret;
+ me.concat(this.parents()).some(function(node) {
+ if(node.is(query)) {
+ toret = node;
+ }
+ return !!toret || (!node.sameNode(this) && node.isContextRoot());
+ }.bind(this));
+
+ return toret;
+ },
+ isContextRoot: function() {
+ var me = this.nodeType === Node.ELEMENT_NODE ? [this] : [],
+ toret = false;
+ if(!this.parent()) {
+ return true;
+ }
+ me.concat(this.parents()).some(function(node) {
+ if(_.isFunction(node.object.isContextRoot) && node.object.isContextRoot(this)) {
+ toret = true;
+ return true;
+ }
+ }.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());
+ }