Skip to content

Commit 020ee4a

Browse files
author
arottier
committed
Add mutation observer init options elementHasAttributeNameFilter and elementLocalNameFilter
1 parent 88c2569 commit 020ee4a

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

dom.bs

+83
Original file line numberDiff line numberDiff line change
@@ -3398,6 +3398,19 @@ dictionary MutationObserverInit {
33983398
<a>attribute</a> mutations need to be
33993399
observed and {{MutationObserverInit/attributes}} is true
34003400
or omitted.
3401+
3402+
<dt>{{MutationObserverInit/elementHasAttributeNameFilter}}
3403+
<dd>Set to a list of <a>attribute</a>
3404+
<a for=Attr>local names</a> (without <a for=Attr>namespace</a>) to observe changes
3405+
to the presence of an elements <a>attributes</a>.
3406+
3407+
<dt>{{MutationObserverInit/elementLocalNameFilter}}
3408+
<dd>Set to a list of <a>element</a>
3409+
<a for=Element>local names</a> (without <a for=Attr>namespace</a>) to observe
3410+
changes to the presence of specific <a>element</a> <a for=Element>local names</a>
3411+
if not all <a>element</a> <a for=Element>local names</a> need to be
3412+
observed and {{MutationObserverInit/attributes}} is true
3413+
or omitted.
34013414
</dl>
34023415

34033416
<dt><code><var>observer</var> . {{disconnect()}}</code>
@@ -3437,6 +3450,14 @@ method, when invoked, must run these steps:
34373450
<var>options</var>'s {{MutationObserverInit/characterData}} is omitted, then set
34383451
<var>options</var>'s {{MutationObserverInit/characterData}} to true.
34393452

3453+
<li><p>If <var>options</var>'s {{MutationObserverInit/elementHasAttributeNameFilter}} is present and
3454+
<var>options</var>'s {{MutationObserverInit/childList}} is omitted, then set
3455+
<var>options</var>'s {{MutationObserverInit/childList}} to true.
3456+
3457+
<li><p>If <var>options</var>'s {{MutationObserverInit/elementLocalNameFilter}} is present and
3458+
<var>options</var>'s {{MutationObserverInit/childList}} is omitted, then set
3459+
<var>options</var>'s {{MutationObserverInit/childList}} to true.
3460+
34403461
<li><p>If none of <var>options</var>'s {{MutationObserverInit/childList}},
34413462
{{MutationObserverInit/attributes}}, and {{MutationObserverInit/characterData}} is true, then
34423463
<a>throw</a> a <code>TypeError</code>.
@@ -3453,6 +3474,14 @@ method, when invoked, must run these steps:
34533474
<var>options</var>'s {{MutationObserverInit/characterData}} is false, then <a>throw</a> a
34543475
<code>TypeError</code>.
34553476

3477+
<li><p>If <var>options</var>'s {{MutationObserverInit/elementHasAttributeNameFilter}} is present and
3478+
<var>options</var>'s {{MutationObserverInit/childList}} is false, then <a>throw</a> a
3479+
<code>TypeError</code>.
3480+
3481+
<li><p>If <var>options</var>'s {{MutationObserverInit/elementLocalNameFilter}} is present and
3482+
<var>options</var>'s {{MutationObserverInit/childList}} is false, then <a>throw</a> a
3483+
<code>TypeError</code>.
3484+
34563485
<li>
34573486
<p><a for=list>For each</a> <var>registered</var> of <var>target</var>'s
34583487
<a>registered observer list</a>, if <var>registered</var>'s
@@ -3594,6 +3623,60 @@ run these steps:
35943623
<ol>
35953624
<li><p>Assert: either <var>addedNodes</var> or <var>removedNodes</var> <a for=set>is not empty</a>.
35963625

3626+
<li><p>If either <var>options</var>'s' {{MutationObserverInit/elementLocalNameFilter}} or
3627+
{{MutationObserverInit/elementHasAttributeNameFilter}} is present, then:
3628+
3629+
<ol>
3630+
<li><p>Let <var>nodeAttributesList</var> be <var>nodeAttributesList</var> of the node's attributes, "<code>node.getAttributeNames()</code>".
3631+
3632+
<li><p>Let <var>filteredAddedNodes</var> be an empty <a for=/>list</a>.
3633+
3634+
<li><p>Let <var>filterRemovedNodes</var> be an empty <a for=/>list</a>.
3635+
3636+
<li>
3637+
<p>For each <var>node</var> in <var>addedNodes</var></a>.
3638+
3639+
<li>
3640+
<p>If none of the following are true
3641+
3642+
<ul class=brief>
3643+
<li>if <var>options</var>'s
3644+
{{MutationObserverInit/elementLocalNameFilter}} is present, and
3645+
"<code>node.localName</code>" is in {{MutationObserverInit/elementLocalNameFilter}}
3646+
3647+
<li><var>options</var>'s {{MutationObserverInit/elementHasAttributeNameFilter}} is
3648+
present,and <var>options</var>'s {{MutationObserverInit/elementHasAttributeNameFilter}}
3649+
contains any of the attribute name in <var>nodeAttributesList</var>
3650+
</ul>
3651+
<p>then:
3652+
<ol>
3653+
<li><p><a for=queue>Enqueue</a> <var>record</var> node in <var>filteredAddedNodes</var>
3654+
</ol>
3655+
3656+
<li><p>For each <var>node</var> in <var>removedNodes</var></a>.
3657+
<li>
3658+
<p>If none of the following are true
3659+
<ul class=brief>
3660+
<li>if <var>options</var>'s
3661+
{{MutationObserverInit/elementLocalNameFilter}} is present, and
3662+
"<code>node.localName</code>" is in {{MutationObserverInit/elementLocalNameFilter}}
3663+
<li>if <var>options</var>'s
3664+
{{MutationObserverInit/elementHasAttributeNameFilter}} is present,and <var>options</var>'s
3665+
{{MutationObserverInit/elementHasAttributeNameFilter}} contains any of the attribute names
3666+
in <var>nodeAttributesList</var>
3667+
</ul>
3668+
<p>then:
3669+
<ol>
3670+
<li><p><a for=queue>Enqueue</a> <var>record</var> node in <var>filterRemovedNodes</var>
3671+
</ol>
3672+
3673+
<li><p>Assert: either <var>filteredAddedNodes</var> or <var>filteredRemovedNodes</var> <a for=set>is not empty</a>.
3674+
3675+
<li><p>Set <var>addedNodes</var> to <var>filteredAddedNodes</var>
3676+
3677+
<li><p>Set <var>removedNodes</var> to <var>filteredRemovedNodes</var>
3678+
</ol>
3679+
35973680
<li><p><a>Queue a mutation record</a> of "<code>childList</code>" for <var>target</var> with
35983681
null, null, null, <var>addedNodes</var>, <var>removedNodes</var>, <var>previousSibling</var>,
35993682
and <var>nextSibling</var>.

0 commit comments

Comments
 (0)