DOM
SourceThe pointerBeforeReferenceNode
getter steps
are to return this’s pointer before reference.
In all current engines.
Firefox3.5+Safari3+Chrome1+ Opera9+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari3+Chrome for Android18+Android WebView1+Samsung Internet1.0+Opera Mobile10.1+
The whatToShow
getter steps are to return this’s whatToShow.
In all current engines.
Firefox3.5+Safari3+Chrome1+ Opera9+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari3+Chrome for Android18+Android WebView1+Samsung Internet1.0+Opera Mobile10.1+
The filter
getter steps are to return this’s filter.
To traverse, given a NodeIterator
object iterator and a direction direction, run these steps:
In all current engines.
Firefox3.5+Safari3+Chrome1+ Opera9+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari3+Chrome for Android18+Android WebView1+Samsung Internet1.0+Opera Mobile10.1+
The nextNode()
method steps are to return the
result of traversing with this and next.
In all current engines.
Firefox3.5+Safari3+Chrome1+ Opera9+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari3+Chrome for Android18+Android WebView1+Samsung Internet1.0+Opera Mobile10.1+
The previousNode()
method steps are to return the
result of traversing with this and previous.
The detach()
method steps are to do nothing. Its functionality (disabling a NodeIterator
object) was removed, but the method
itself is preserved for compatibility.
In all current engines.
Firefox4+Safari3+Chrome1+ Opera9+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari3+Chrome for Android18+Android WebView3+Samsung Internet1.0+Opera Mobile10.1+
[Exposed=Window]
interface TreeWalker
{ [SameObject] readonly attribute Node root; readonly attribute unsigned long whatToShow; readonly attribute NodeFilter? filter; attribute Node currentNode; Node? parentNode(); Node? firstChild(); Node? lastChild(); Node? previousSibling(); Node? nextSibling(); Node? previousNode(); Node? nextNode();
};
TreeWalker
objects can be created using the createTreeWalker()
method on Document
objects.
Each TreeWalker
object has an associated current (a node).
As mentioned earlier TreeWalker
objects have an associated root, whatToShow, and filter as well.
In all current engines.
Firefox4+Safari3+Chrome1+ Opera9+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari3+Chrome for Android18+Android WebView3+Samsung Internet1.0+Opera Mobile10.1+
The root
getter steps are to return this’s root.
In all current engines.
Firefox4+Safari3+Chrome1+ Opera9+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari3+Chrome for Android18+Android WebView3+Samsung Internet1.0+Opera Mobile10.1+
The whatToShow
getter steps are to return this’s whatToShow.
In all current engines.
Firefox4+Safari3+Chrome1+ Opera9+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari3+Chrome for Android18+Android WebView3+Samsung Internet1.0+Opera Mobile10.1+
The filter
getter steps are to return this’s filter.
In all current engines.
Firefox4+Safari3+Chrome1+ Opera9+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari3+Chrome for Android18+Android WebView3+Samsung Internet1.0+Opera Mobile10.1+
The currentNode
getter steps are to return this’s current.
The currentNode
setter steps are to set this’s current to the given value.
In all current engines.
Firefox4+Safari3+Chrome1+ Opera9+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari3+Chrome for Android18+Android WebView3+Samsung Internet1.0+Opera Mobile10.1+
The parentNode()
method steps are:
To traverse children, given a walker and type, run these steps:
-
Let node be walker’s current.
-
Set node to node’s first child if type is first, and node’s last child if type is last.
-
While node is non-null:
-
Let result be the result of filtering node within walker.
-
If result is
FILTER_ACCEPT
, then set walker’s current to node and return node. -
If result is
FILTER_SKIP
, then:-
Let child be node’s first child if type is first, and node’s last child if type is last.
-
If child is non-null, then set node to child and continue.
-
-
While node is non-null:
-
Let sibling be node’s next sibling if type is first, and node’s previous sibling if type is last.
-
If sibling is non-null, then set node to sibling and break.
-
Let parent be node’s parent.
-
If parent is null, walker’s root, or walker’s current, then return null.
-
Set node to parent.
-
-
-
Return null.
In all current engines.
Firefox4+Safari3+Chrome1+ Opera9+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari3+Chrome for Android18+Android WebView3+Samsung Internet1.0+Opera Mobile10.1+
The firstChild()
method steps are to traverse children with this and first.
In all current engines.
Firefox4+Safari3+Chrome1+ Opera9+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari3+Chrome for Android18+Android WebView3+Samsung Internet1.0+Opera Mobile10.1+
The lastChild()
method steps are to traverse children with this and last.
To traverse siblings, given a walker and type, run these steps:
In all current engines.
Firefox4+Safari3+Chrome1+ Opera9+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari3+Chrome for Android18+Android WebView3+Samsung Internet1.0+Opera Mobile10.1+
The nextSibling()
method steps are to traverse siblings with this and next.
In all current engines.
Firefox4+Safari3+Chrome1+ Opera9+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari3+Chrome for Android18+Android WebView3+Samsung Internet1.0+Opera Mobile10.1+
The previousSibling()
method steps are to traverse siblings with this and previous.
In all current engines.
Firefox4+Safari3+Chrome1+ Opera9+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari3+Chrome for Android18+Android WebView3+Samsung Internet1.0+Opera Mobile10.1+
The previousNode()
method steps are:
In all current engines.
Firefox4+Safari3+Chrome1+ Opera9+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari3+Chrome for Android18+Android WebView3+Samsung Internet1.0+Opera Mobile10.1+
The nextNode()
method steps are:
In all current engines.
Firefox2+Safari3+Chrome1+ Opera9+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari3+Chrome for Android18+Android WebView1+Samsung Internet1.0+Opera Mobile10.1+
In all current engines.
Firefox2+Safari3+Chrome1+ Opera9+Edge79+ Edge (Legacy)12+IE9+ Firefox for Android4+iOS Safari3+Chrome for Android18+Android WebView1+Samsung Internet1.0+Opera Mobile10.1+
[Exposed=Window]
callback interface NodeFilter
{ // Constants for acceptNode() const = 0x10; // legacy const = 0x20; // legacy const = 0x800; // legacy ();
};
NodeFilter
objects can be used as filter for NodeIterator
and TreeWalker
objects and also provide constants for their whatToShow bitmask. A NodeFilter
object is typically implemented as a
JavaScript function.
These constants can be used as filter return value:
FILTER_ACCEPT
(1);FILTER_REJECT
(2);FILTER_SKIP
(3).
These constants can be used for whatToShow:
SHOW_ALL
(4294967295, FFFFFFFF in hexadecimal);SHOW_ELEMENT
(1);SHOW_ATTRIBUTE
(2);SHOW_TEXT
(4);SHOW_CDATA_SECTION
(8);SHOW_PROCESSING_INSTRUCTION
(64, 40 in hexadecimal);- (128, 80 in hexadecimal);
SHOW_DOCUMENT
(256, 100 in hexadecimal);SHOW_DOCUMENT_TYPE
(512, 200 in hexadecimal);SHOW_DOCUMENT_FRAGMENT
(1024, 400 in hexadecimal).
Read Next page