The TreeWalker.filter read-only property returns a NodeFilter that is the filtering object associated with the TreeWalker.

When creating the TreeWalker, the filter object is passed in as the third parameter, and its method NodeFilter.acceptNode() is called on every single node to determine whether or not to accept it.


nodeFilter = treeWalker.filter;


var treeWalker = document.createTreeWalker(
    { acceptNode: function(node) { return NodeFilter.FILTER_ACCEPT; } },
nodeFilter = treeWalker.filter; // document.body in this case


Specification Status Comment
The definition of 'TreeWalker.filter' in that specification.
Living Standard No change from Document Object Model (DOM) Level 2 Traversal and Range Specification
Document Object Model (DOM) Level 2 Traversal and Range Specification
The definition of 'TreeWalker.filter' in that specification.
Obsolete Initial definition.

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1.0 (Yes) 2.0 (1.8.1) 9.0 9.0 3.0
Feature Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) 1.0 (1.8.1) (Yes) 9.0 3.0

See also

Document Tags and Contributors

Contributors to this page: erikadoyle, Sebastianz, teoli, Prome, Prachi_Dighe, Sheppy, Warhammerkid
Last updated by: erikadoyle,