-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add elementHasAttributeNameFilter and elementLocalNameFilter to MutationObserver options #1
base: master
Are you sure you want to change the base?
Conversation
Tests: web-platform-tests/wpt#22524 Fixes whatwg#478. Closes whatwg#755 and closes whatwg#835.
[TreatNullAs=EmptyString] → [LegacyNullToEmptyString] and [Unforgeable] → [LegacyUnforgeable]. Follows whatwg/webidl#870.
@@ -3437,6 +3450,14 @@ method, when invoked, must run these steps: | |||
<var>options</var>'s {{MutationObserverInit/characterData}} is omitted, then set | |||
<var>options</var>'s {{MutationObserverInit/characterData}} to true. | |||
|
|||
<li><p>If <var>options</var>'s {{MutationObserverInit/elementHasAttributeFilter}} is present and | |||
<var>options</var>'s {{MutationObserverInit/childList}} is omitted, then set |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remind me why we decided that childList
should be set to true when either of these options are enabled. I think it's ok to just throw typeError, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It implicitly defaults to checking the immediate node's childList
. Otherwise it's a bit wonky to have to set elementHasAttributeNameFilter
and set childList
to true every time you want to use elementHasAttributeNameFilter
dom.bs
Outdated
{{MutationObserverInit/elementHasAttributeFilter}} is present, then: | ||
|
||
<ol> | ||
<li><p>Let <var>nodeAttributesList</var> be <var>nodeAttributesList</var> of the node's attributes, "<code>node.attributes.keys</code>". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node.attribute.keys
may not be accurate. Try to find the appropriate API to capture the attributeNames of a node.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly element.getAttributeNames
: https://developer.mozilla.org/en-US/docs/Web/API/Element/getAttributeNames however, this is on element
, not node
Seems like element.getAttributeNames()
is rather new-ish. Not sure if there is a preference on choosing APIs or code that is more backwards compatible.
Should I use the handy API getAttributeNames
, or in the code block, write the polyfill code for it?
dom.bs
Outdated
|
||
<li><var>options</var>'s {{MutationObserverInit/elementHasAttributeFilter}} is | ||
present,and <var>options</var>'s {{MutationObserverInit/elementHasAttributeFilter}} | ||
contains any of the attributes in <var>nodeAttributesList</var> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attributes
==> attribute names
dom.bs
Outdated
@@ -3398,6 +3398,19 @@ dictionary MutationObserverInit { | |||
<a>attribute</a> mutations need to be | |||
observed and {{MutationObserverInit/attributes}} is true | |||
or omitted. | |||
|
|||
<dt>{{MutationObserverInit/elementHasAttributeFilter}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are filtering based on just attribute names, right? So, shouldn't it just be elementHasAttributeNameFilter
?
dom.bs
Outdated
"<code>node.localName</code>" is in {{MutationObserverInit/elementLocalNameFilter}} | ||
<li>if <var>options</var>'s | ||
{{MutationObserverInit/elementHasAttributeFilter}} is present,and <var>options</var>'s | ||
{{MutationObserverInit/elementHasAttributeFilter}} contains any of the attributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
attribute names
624f14f
to
020ee4a
Compare
e37b25c
to
19960d9
Compare
…elementLocalNameFilter
d00431a
to
d1c9cb6
Compare
For whatwg/html#5909. Tests: web-platform-tests/wpt#25794. Co-authored-by: Anne van Kesteren <[email protected]>
This is for use with whatwg/html#5912, which restricts access to ElementInternals's shadowRoot property for shadow roots which were pre-existing before a custom element upgrade/construction. See the discussion in WICG/webcomponents#871 (comment) for more context.
Now that the relevant W3C documents redirect here, there is no need to explain the differences with them. The Historical section now details what has been removed, without acknowledging the historical organization of those features.
Now that the default semantics are to throw, we need to be more explicit about catching.
Helps with whatwg/meta#174.
It needs to pass this rather than an undefined variable. Also clean up the algorithm a bit. Fixes whatwg#921.
Once you have thrown for all QName cases, you can no longer throw for Name cases. Tested as part of whatwg#423. Also cleanup createElementNS()'s domintro. Fixes whatwg#671 and closes whatwg#675.
This comma got dropped in 83037a1 but the sentence isn’t grammatical without it, so this change restores it.
Returns an aborted AbortSignal. Tests: web-platform-tests/wpt#28003. Fixes whatwg#959.
Explainer: https://github.com/WICG/webcomponents/blob/gh-pages/proposals/Imperative-Shadow-DOM-Distribution-API.md. Corresponding HTML PR: whatwg/html#6561. Closes whatwg#860 by superseding it. Co-authored-by: Yu Han <[email protected]>
In particular adopt the getter/setter/method/constructor steps pattern.
Mainly to make the document more consistent which should make it easier to change going forward.
It has been deprecated for over a year. Now it is obsolete.
Copied from https://wiki.whatwg.org/wiki/DOM_XSLTProcessor. Part of whatwg#181.
1. Address numerous xref issues around the term node and prevent some from occurring for the term children. 2. Embrace Attr as a node even more. 3. Rely on Web IDL's implements and interface primitives to reduce the opportunities for confusion. Fixes whatwg#597, fixes whatwg#636, fixes whatwg#719, and fixes whatwg#770.
Adds additional options when constructing a
MutationObserver
.MutationObserverInit now contains two additional options:
elementHasAttributeNameFilter
andelementLocalNameFilter
which are used to enhance the precision of filtering DOM nodes to observe.See whatwg#398 for the background.