},
containsNode: function(node) {
- return node._$.parents().index(this.root._$) !== -1;
+ return this.root && (node.nativeNode === this.root.nativeNode || node._$.parents().index(this.root._$) !== -1);
},
wrapNodes: function(params) {
doc.loadXML('<header></header>');
expect(doc.root.getTagName()).to.equal('header');
});
+
+ it('knows if it contains an ElementNode in its tree', function() {
+ var doc = getDocumentFromXML('<root><a></a>text</root>'),
+ root = doc.root,
+ a = root.contents()[0],
+ text = root.contents()[1];
+
+ expect(doc.containsNode(root)).to.equal(true, 'contains its root');
+ expect(doc.containsNode(a)).to.equal(true, 'contains Element Node');
+ expect(doc.containsNode(text)).to.equal(true, 'contains Text Node');
+ });
});
describe('Basic ElementNode properties', function() {