@@ -9901,20 +9901,21 @@ and {{Range/getBoundingClientRect()}} methods are defined in other specification
99019901<p> {{NodeIterator}} and {{TreeWalker}} objects can be used to filter and traverse <a for=/>node</a>
99029902<a>trees</a> .
99039903
9904- <p> Each {{NodeIterator}} and {{TreeWalker}} object has an associated
9905- <dfn noexport id=concept-traversal-active for=traversal>active flag </dfn> to avoid recursive
9906- invocations. It is initially unset .
9904+ <p> Each {{NodeIterator}} and {{TreeWalker}} object has an associated boolean
9905+ <dfn id=concept-traversal-active for=traversal>is active </dfn> to avoid recursive invocations. It is
9906+ initially false .
99079907
99089908<p> Each {{NodeIterator}} and {{TreeWalker}} object also has an associated
9909- <dfn noexport id=concept-traversal-root for=traversal>root</dfn> (a <a for=/>node</a> ), a
9910- <dfn noexport id=concept-traversal-whattoshow for=traversal>whatToShow</dfn> (a bitmask), and a
9911- <dfn noexport id=concept-traversal-filter for=traversal>filter</dfn> (a callback).
9909+ <dfn id=concept-traversal-root for=traversal>root</dfn> (a <a for=/>node</a> ), a
9910+ <dfn id=concept-traversal-whattoshow for=traversal>whatToShow</dfn> (a bitmask), and a
9911+ <dfn id=concept-traversal-filter for=traversal>filter</dfn> (a callback).
99129912
9913+ <div algorithm>
99139914<p> To <dfn noexport id=concept-node-filter>filter</dfn> a <a for=/>node</a> <var> node</var> within
9914- a {{NodeIterator}} or {{TreeWalker}} object <var> traverser</var> , run these steps :
9915+ a {{NodeIterator}} or {{TreeWalker}} object <var> traverser</var> :
99159916
99169917<ol>
9917- <li><p> If <var> traverser</var> 's <a for=traversal>active flag </a> is set , then throw an
9918+ <li><p> If <var> traverser</var> 's <a for=traversal>is active </a> is true , then throw an
99189919 "{{InvalidStateError!!exception}} " {{DOMException}} .
99199920
99209921 <li><p> Let <var> n</var> be <var> node</var> 's {{Node/nodeType}} attribute value − 1.
@@ -9927,17 +9928,18 @@ a {{NodeIterator}} or {{TreeWalker}} object <var>traverser</var>, run these step
99279928 <li><p> If <var> traverser</var> 's <a for=traversal>filter</a> is null, then return
99289929 {{NodeFilter/FILTER_ACCEPT}} .
99299930
9930- <li><p> Set <var> traverser</var> 's <a for=traversal>active flag </a> .
9931+ <li><p> Set <var> traverser</var> 's <a for=traversal>is active </a> to true .
99319932
99329933 <li><p> Let <var> result</var> be the return value of <a>call a user object's operation</a> with
99339934 <var> traverser</var> 's <a for=traversal>filter</a> , "<code> acceptNode</code> ", and
9934- « <var> node</var> ». If this throws an exception, then unset <var> traverser</var> 's
9935- <a for=traversal>active flag </a> and rethrow the exception.
9935+ « <var> node</var> ». If this throws an exception, then set <var> traverser</var> 's
9936+ <a for=traversal>is active </a> to false and rethrow the exception.
99369937
9937- <li><p> Unset <var> traverser</var> 's <a for=traversal>active flag </a> .
9938+ <li><p> Set <var> traverser</var> 's <a for=traversal>is active </a> to false .
99389939
99399940 <li><p> Return <var> result</var> .
99409941</ol>
9942+ </div>
99419943
99429944
99439945<h3 id="interface-nodeiterator">Interface {{NodeIterator}}</h3>
@@ -9970,11 +9972,13 @@ filter matches any <a for=/>node</a>.
99709972<a for=/>node</a> ) and <dfn for=NodeIterator>pointer before reference</dfn> (a boolean).
99719973
99729974<p class=note> As mentioned earlier, {{NodeIterator}} objects have an associated
9973- <a for=traversal>active flag </a> , <a for=traversal>root</a> , <a for=traversal>whatToShow</a> , and
9975+ <a for=traversal>is active </a> , <a for=traversal>root</a> , <a for=traversal>whatToShow</a> , and
99749976<a for=traversal>filter</a> as well.
99759977
9978+ <div algorithm>
99769979<p> The <dfn id=nodeiterator-pre-removing-steps><code>NodeIterator</code> pre-remove steps</dfn>
9977- given a <var> nodeIterator</var> and <var> toBeRemovedNode</var> , are as follows:
9980+ given a {{NodeIterator}} object <var> nodeIterator</var> and <a for=/>node</a>
9981+ <var> toBeRemovedNode</var> , are:
99789982
99799983<ol>
99809984 <li><p> If <var> toBeRemovedNode</var> is not an <a for=tree>inclusive ancestor</a> of
@@ -9988,44 +9992,52 @@ given a <var>nodeIterator</var> and <var>toBeRemovedNode</var>, are as follows:
99889992 <li><p> Let <var> next</var> be <var> toBeRemovedNode</var> 's first <a>following</a>
99899993 <a for=/>node</a> that is an <a>inclusive descendant</a> of <var> nodeIterator</var> 's
99909994 <a for=traversal>root</a> and is not an <a>inclusive descendant</a> of
9991- <var> toBeRemovedNode</var> , and null if there is no such <a for=/>node</a> .
9995+ <var> toBeRemovedNode</var> , if there is such a <a for=/>node</a> ; otherwise null .
99929996
99939997 <li><p> If <var> next</var> is non-null, then set <var> nodeIterator</var> 's
99949998 <a for=NodeIterator>reference</a> to <var> next</var> and return.
99959999
9996- <li>
9997- <p> Otherwise, set <var> nodeIterator</var> 's <a for=NodeIterator>pointer before reference</a> to
9998- false.
9999-
10000- <p class=note> Steps are not terminated here.
10000+ <li><p> Set <var> nodeIterator</var> 's <a for=NodeIterator>pointer before reference</a> to false.
1000110001 </ol>
1000210002
1000310003 <li><p> Set <var> nodeIterator</var> 's <a for=NodeIterator>reference</a> to
1000410004 <var> toBeRemovedNode</var> 's <a for=tree>parent</a>, if <var>toBeRemovedNode</var>' s
10005- <a>previous sibling</a> is null, and to the <a>inclusive descendant</a> of
10006- <var> toBeRemovedNode</var> 's <a>previous sibling</a> that appears last in <a>tree order</a>
10007- otherwise.
10005+ <a>previous sibling</a> is null; otherwise to the <a>inclusive descendant</a> of
10006+ <var> toBeRemovedNode</var> 's <a>previous sibling</a> that appears last in <a>tree order</a> .
1000810007</ol>
10008+ </div>
1000910009
1001010010<hr>
1001110011
10012+ <div algorithm>
1001210013<p> The <dfn attribute for=NodeIterator><code>root</code></dfn> getter steps are to return
1001310014<a>this</a> 's <a for=traversal>root</a> .
10015+ </div>
1001410016
10017+ <div algorithm>
1001510018<p> The <dfn attribute for=NodeIterator><code>referenceNode</code></dfn> getter steps are to return
1001610019<a>this</a> 's <a for=NodeIterator>reference</a> .
10020+ </div>
1001710021
10022+ <div algorithm>
1001810023<p> The <dfn attribute for=NodeIterator><code>pointerBeforeReferenceNode</code></dfn> getter steps
1001910024are to return <a>this</a> 's <a for=NodeIterator>pointer before reference</a> .
10025+ </div>
1002010026
10027+ <div algorithm>
1002110028<p> The <dfn attribute for=NodeIterator><code>whatToShow</code></dfn> getter steps are to return
1002210029<a>this</a> 's <a for=traversal>whatToShow</a> .
10030+ </div>
1002310031
10032+ <div algorithm>
1002410033<p> The <dfn attribute for=NodeIterator><code>filter</code></dfn> getter steps are to return
1002510034<a>this</a> 's <a for=traversal>filter</a> .
10035+ </div>
1002610036
10037+ <div algorithm>
1002710038<p> To <dfn export id=concept-nodeiterator-traverse for=NodeIterator>traverse</dfn> , given a
10028- {{NodeIterator}} object <var> iterator</var> and a direction <var> direction</var> , run these steps:
10039+ {{NodeIterator}} object <var> iterator</var> and "<code> next</code> " or "<code> previous</code> "
10040+ <var> type</var> :
1002910041
1003010042<ol>
1003110043 <li><p> Let <var> node</var> be <var> iterator</var> 's <a for=NodeIterator>reference</a> .
@@ -10038,27 +10050,28 @@ are to return <a>this</a>'s <a for=NodeIterator>pointer before reference</a>.
1003810050
1003910051 <ol>
1004010052 <li>
10041- <p> Branch on <var> direction </var> :
10053+ <p> If <var> type </var> is <code> next </code> " :
1004210054
10043- <dl class=switch>
10044- <dt> next
10045- <dd>
10046- <p> If <var> beforeNode</var> is false, then set <var> node</var> to the first <a for=/>node</a>
10047- <a>following</a> <var> node</var> in <var> iterator</var> 's
10048- <a for=NodeIterator>iterator collection</a> . If there is no such <a for=/>node</a> , then
10049- return null.
10055+ <ol>
10056+ <li><p> If <var> beforeNode</var> is false, then set <var> node</var> to the first
10057+ <a for=/>node</a> <a>following</a> <var> node</var> in <var> iterator</var> 's
10058+ <a for=NodeIterator>iterator collection</a> . If there is no such <a for=/>node</a> , then return
10059+ null.
1005010060
10051- <p> If <var> beforeNode</var> is true, then set it to false.
10061+ <li><p> If <var> beforeNode</var> is true, then set it to false.
10062+ </ol>
1005210063
10053- <dt> previous
10054- <dd>
10055- <p> If <var> beforeNode</var> is true, then set <var> node</var> to the first <a for=/>node</a>
10056- <a>preceding</a> <var> node</var> in <var> iterator</var> 's
10057- <a for=NodeIterator>iterator collection</a> . If there is no such <a for=/>node</a> , then
10058- return null.
10064+ <li>
10065+ <p> Otherwise:
1005910066
10060- <p> If <var> beforeNode</var> is false, then set it to true.
10061- </dl>
10067+ <ol>
10068+ <li><p> If <var> beforeNode</var> is true, then set <var> node</var> to the first
10069+ <a for=/>node</a> <a>preceding</a> <var> node</var> in <var> iterator</var> 's
10070+ <a for=NodeIterator>iterator collection</a> . If there is no such <a for=/>node</a> , then return
10071+ null.
10072+
10073+ <li><p> If <var> beforeNode</var> is false, then set it to true.
10074+ </ol>
1006210075
1006310076 <li><p> Let <var> result</var> be the result of <a for=/>filtering</a> <var> node</var> within
1006410077 <var> iterator</var> .
@@ -10073,16 +10086,23 @@ are to return <a>this</a>'s <a for=NodeIterator>pointer before reference</a>.
1007310086
1007410087 <li><p> Return <var> node</var> .
1007510088</ol>
10089+ </div>
1007610090
10091+ <div algorithm>
1007710092<p> The <dfn method for=NodeIterator><code>nextNode()</code></dfn> method steps are to return the
10078- result of <a for=NodeIterator>traversing</a> with <a>this</a> and next.
10093+ result of <a for=NodeIterator>traversing</a> with <a>this</a> and "<code> next</code> ".
10094+ </div>
1007910095
10096+ <div algorithm>
1008010097<p> The <dfn method for=NodeIterator><code>previousNode()</code></dfn> method steps are to return the
10081- result of <a for=NodeIterator>traversing</a> with <a>this</a> and previous.
10098+ result of <a for=NodeIterator>traversing</a> with <a>this</a> and "<code> previous</code> ".
10099+ </div>
1008210100
10101+ <div algorithm>
1008310102<p> The <dfn method for=NodeIterator><code>detach()</code></dfn> method steps are to do nothing.
1008410103<span class=note> Its functionality (disabling a {{NodeIterator}} object) was removed, but the method
1008510104itself is preserved for compatibility.</span>
10105+ </div>
1008610106
1008710107
1008810108<h3 id=interface-treewalker>Interface {{TreeWalker}}</h3>
@@ -10113,23 +10133,34 @@ method on {{Document}} objects.
1011310133<p class=note> As mentioned earlier {{TreeWalker}} objects have an associated
1011410134<a for=traversal>root</a> , <a for=traversal>whatToShow</a> , and <a for=traversal>filter</a> as well.
1011510135
10136+ <div algorithm>
1011610137<p> The <dfn attribute for=TreeWalker><code>root</code></dfn> getter steps are to return
1011710138<a>this</a> 's <a for=traversal>root</a> .
10139+ </div>
1011810140
10141+ <div algorithm>
1011910142<p> The <dfn attribute for=TreeWalker><code>whatToShow</code></dfn> getter steps are to return
1012010143<a>this</a> 's <a for=traversal>whatToShow</a> .
10144+ </div>
1012110145
10146+ <div algorithm>
1012210147<p> The <dfn attribute for=TreeWalker><code>filter</code></dfn> getter steps are to return
1012310148<a>this</a> 's <a for=traversal>filter</a> .
10149+ </div>
1012410150
10151+ <div algorithm>
1012510152<p> The <dfn attribute for=TreeWalker><code>currentNode</code></dfn> getter steps are to return
1012610153<a>this</a> 's <a for=TreeWalker>current</a> .
10154+ </div>
1012710155
10156+ <div algorithm="TreeWalker/currentNode setter">
1012810157<p> The {{TreeWalker/currentNode}} setter steps are to set <a>this</a> 's
1012910158<a for=TreeWalker>current</a> to the given value.
10159+ </div>
1013010160
1013110161<hr>
1013210162
10163+ <div algorithm>
1013310164<p> The <dfn method for=TreeWalker><code>parentNode()</code></dfn> method steps are:
1013410165
1013510166<ol>
@@ -10149,15 +10180,18 @@ method on {{Document}} objects.
1014910180
1015010181 <li><p> Return null.
1015110182</ol>
10183+ </div>
1015210184
10185+ <div algorithm>
1015310186<p> To <dfn noexport for=TreeWalker id=concept-traverse-children>traverse children</dfn> , given a
10154- <var> walker</var> and <var> type</var> , run these steps:
10187+ {{TreeWalker}} object <var> walker</var> and "<code> first</code> " or "<code> last</code> "
10188+ <var> type</var> :
1015510189
1015610190<ol>
1015710191 <li><p> Let <var> node</var> be <var> walker</var> 's <a for=TreeWalker>current</a> .
1015810192
1015910193 <li><p> Set <var> node</var> to <var> node</var> 's <a for=tree>first child</a> if <var> type</var> is
10160- first, and <var> node</var> 's <a for=tree>last child</a> if <var> type </var> is last .
10194+ " <code> first</code> "; otherwise to <var> node</var> 's <a for=tree>last child</a> .
1016110195
1016210196 <li>
1016310197 <p> While <var> node</var> is non-null:
@@ -10174,7 +10208,7 @@ method on {{Document}} objects.
1017410208
1017510209 <ol>
1017610210 <li><p> Let <var> child</var> be <var> node</var> 's <a for=tree>first child</a> if <var> type</var>
10177- is first, and <var> node</var> 's <a for=tree>last child</a> if <var> type </var> is last .
10211+ is " <code> first</code> "; otherwise <var> node</var> 's <a for=tree>last child</a> .
1017810212
1017910213 <li><p> If <var> child</var> is non-null, then set <var> node</var> to <var> child</var> and
1018010214 <a for=iteration>continue</a> .
@@ -10185,8 +10219,8 @@ method on {{Document}} objects.
1018510219
1018610220 <ol>
1018710221 <li><p> Let <var> sibling</var> be <var> node</var> 's <a for=tree>next sibling</a> if
10188- <var> type</var> is first, and <var> node</var> 's <a for=tree>previous sibling</a> if
10189- <var> type </var> is last .
10222+ <var> type</var> is " <code> first</code> "; otherwise <var> node</var> 's
10223+ <a for=tree>previous sibling</a> .
1019010224
1019110225 <li><p> If <var> sibling</var> is non-null, then set <var> node</var> to <var> sibling</var> and
1019210226 <a for=iteration>break</a> .
@@ -10202,15 +10236,21 @@ method on {{Document}} objects.
1020210236
1020310237 <li><p> Return null.
1020410238</ol>
10239+ </div>
1020510240
10241+ <div algorithm>
1020610242<p> The <dfn method for=TreeWalker><code>firstChild()</code></dfn> method steps are to
10207- <a>traverse children</a> with <a>this</a> and first.
10243+ <a>traverse children</a> with <a>this</a> and "<code> first</code> ".
10244+ </div>
1020810245
10246+ <div algorithm>
1020910247<p> The <dfn method for=TreeWalker><code>lastChild()</code></dfn> method steps are to
10210- <a>traverse children</a> with <a>this</a> and last.
10248+ <a>traverse children</a> with <a>this</a> and "<code> last</code> ".
10249+ </div>
1021110250
10212- <p> To <dfn noexport id=concept-traverse-siblings>traverse siblings</dfn> , given a <var> walker</var>
10213- and <var> type</var> , run these steps:
10251+ <div algorithm>
10252+ <p> To <dfn noexport id=concept-traverse-siblings>traverse siblings</dfn> , given a {{TreeWalker}}
10253+ object <var> walker</var> and "<code> next</code> " or "<code> previous</code> " <var> type</var> :
1021410254
1021510255<ol>
1021610256 <li><p> Let <var> node</var> be <var> walker</var> 's <a for=TreeWalker>current</a> .
@@ -10222,8 +10262,8 @@ and <var>type</var>, run these steps:
1022210262
1022310263 <ol>
1022410264 <li><p> Let <var> sibling</var> be <var> node</var> 's <a for=tree>next sibling</a> if
10225- <var> type</var> is next, and <var> node</var> 's <a for=tree>previous sibling</a> if
10226- <var> type </var> is previous .
10265+ <var> type</var> is " <code> next</code> "; otherwise <var> node</var> 's
10266+ <a for=tree>previous sibling</a> .
1022710267
1022810268 <li>
1022910269 <p> While <var> sibling</var> is non-null:
@@ -10238,12 +10278,12 @@ and <var>type</var>, run these steps:
1023810278 <a for=TreeWalker>current</a> to <var> node</var> and return <var> node</var> .
1023910279
1024010280 <li><p> Set <var> sibling</var> to <var> node</var> 's <a for=tree>first child</a> if
10241- <var> type</var> is next, and <var> node </var> 's <a for=tree>last child</a> if < var>type </var> is
10242- previous .
10281+ <var> type</var> is " <code> next </code> "; otherwise to < var>node </var> 's
10282+ <a for=tree>last child</a> .
1024310283
1024410284 <li><p> If <var> result</var> is {{NodeFilter/FILTER_REJECT}} or <var> sibling</var> is null, then
1024510285 set <var> sibling</var> to <var> node</var> 's <a for=tree>next sibling</a> if <var> type</var> is
10246- next, and <var> node</var> 's <a for=tree>previous sibling</a> if <var> type </var> is previous .
10286+ " <code> next</code> "; otherwise to <var> node</var> 's <a for=tree>previous sibling</a> .
1024710287 </ol>
1024810288
1024910289 <li><p> Set <var> node</var> to <var> node</var> 's <a for=tree>parent</a> .
@@ -10255,13 +10295,19 @@ and <var>type</var>, run these steps:
1025510295 {{NodeFilter/FILTER_ACCEPT}} , then return null.
1025610296 </ol>
1025710297</ol>
10298+ </div>
1025810299
10300+ <div algorithm>
1025910301<p> The <dfn method for=TreeWalker><code>nextSibling()</code></dfn> method steps are to
10260- <a>traverse siblings</a> with <a>this</a> and next.
10302+ <a>traverse siblings</a> with <a>this</a> and "<code> next</code> ".
10303+ </div>
1026110304
10305+ <div algorithm>
1026210306<p> The <dfn method for=TreeWalker><code>previousSibling()</code></dfn> method steps are to
10263- <a>traverse siblings</a> with <a>this</a> and previous.
10307+ <a>traverse siblings</a> with <a>this</a> and "<code> previous</code> ".
10308+ </div>
1026410309
10310+ <div algorithm>
1026510311<p> The <dfn method for=TreeWalker><code>previousNode()</code></dfn> method steps are:
1026610312
1026710313<ol>
@@ -10311,7 +10357,9 @@ and <var>type</var>, run these steps:
1031110357
1031210358 <li><p> Return null.
1031310359</ol>
10360+ </div>
1031410361
10362+ <div algorithm>
1031510363<p> The <dfn method for=TreeWalker><code>nextNode()</code></dfn> method steps are:
1031610364
1031710365<ol>
@@ -10362,6 +10410,7 @@ and <var>type</var>, run these steps:
1036210410 <a for=TreeWalker>current</a> to <var> node</var> and return <var> node</var> .
1036310411 </ol>
1036410412</ol>
10413+ </div>
1036510414
1036610415
1036710416<h3 id="interface-nodefilter">Interface {{NodeFilter}}</h3>
0 commit comments