mirror of
https://github.com/jlengrand/webcomponentsjs.git
synced 2026-03-10 08:51:22 +00:00
unable to call document.createTreeWalker without unwrapping root
This commit is contained in:
@@ -338,6 +338,13 @@
|
||||
'hasFeature',
|
||||
]);
|
||||
|
||||
var originalCreateTreeWalker = document.createTreeWalker;
|
||||
function createTreeWalker(root, whatToShow, filter, entityReferenceExpansion){
|
||||
return originalCreateTreeWalker.call(document,unwrap(root), whatToShow, filter, entityReferenceExpansion);
|
||||
}
|
||||
|
||||
document.createTreeWalker = createTreeWalker; // override
|
||||
|
||||
scope.adoptNodeNoRemove = adoptNodeNoRemove;
|
||||
scope.wrappers.DOMImplementation = DOMImplementation;
|
||||
scope.wrappers.Document = Document;
|
||||
|
||||
@@ -677,6 +677,19 @@ htmlSuite('Document', function() {
|
||||
assert.equal('<span is="x-a-span-2"></span>', a3.outerHTML);
|
||||
});
|
||||
|
||||
test('document.createTreeWalker', function() {
|
||||
div = document.body.appendChild(document.createElement('div'));
|
||||
div.innerHTML = '<div myattribute="a"></div>';
|
||||
var treeWalker = document.createTreeWalker(div, NodeFilter.SHOW_ELEMENT, null, null);
|
||||
var found;
|
||||
while (treeWalker.nextNode()) {
|
||||
if (treeWalker.currentNode.hasAttribute("myattribute")){
|
||||
found=treeWalker.currentNode.getAttribute("myattribute")==='a';
|
||||
}
|
||||
}
|
||||
assert.isTrue(found);
|
||||
});
|
||||
|
||||
htmlTest('../html/document-write.html');
|
||||
|
||||
htmlTest('../html/head-then-body.html');
|
||||
|
||||
Reference in New Issue
Block a user