web api instance property
TreeWalker: root property
The TreeWalker.root read-only property returns the root Node that the TreeWalker traverses.
Value
A Node object.
Examples
const treeWalker = document.createTreeWalker(
document.body,
NodeFilter.SHOW_ELEMENT,
{
acceptNode(node) {
return NodeFilter.FILTER_ACCEPT;
},
},
false,
);
root = treeWalker.root; // document.body in this case
Specifications
SpecificationsStandards references are available on the canonical MDN page.
Browser compatibility
Browser compatibilityCompatibility data is available on the canonical MDN page.
See also
- The
TreeWalkerinterface.