Introduce customelementregistry global attribute#12000
Introduce customelementregistry global attribute#12000ja-y-son wants to merge 2 commits intowhatwg:mainfrom
Conversation
|
@annevk Here's the PR for the new custom element registry attribute. |
| <code data-x="attr-customelementregistry">customelementregistry</code> attribute exists; | ||
| otherwise let <var>registry</var> be the result of | ||
| <span data-x="look up a custom element registry">looking up a custom element registry</span> | ||
| given <var>intendedParent</var>.</p></li> |
There was a problem hiding this comment.
Don't we need the same kind of complexity we need as for shadow roots for the same kind of scenario we discussed for them?
There was a problem hiding this comment.
Not sure if I followed here. Could you elaborate on the complexity we need for this attribute that you mentioned above?
There was a problem hiding this comment.
I think we need a separate "keep custom element registry null" flag for whatwg/dom#1423 (comment).
There was a problem hiding this comment.
Added keep custom element registry null concept for the element attribute aligning with the shadowroot counterpart. Also updated whatwg/dom#1437 to include the concept.
|
This should probably have serialization steps similar to |
|
@Jamesernator @annevk
|
Sure, but calling This actually pretty similar to the |
|
I see what you mean. Then here's an open question on serialization if we expect the attribute to be serialized on element using scoped registry I want to verify here: In this case, initialize will give |
That depends how However if they didn't have a registry then yes I'd expect the change in registry would result in a change in serialization (just like any other DOM change). |
|
I believe the intended behavior of cusomelementregistry attribute is that the element with such attribute and the subtree of the element should all get null registry. The foo and bar in above example should get scoped registry, and it sounds like we do want the attribute serialized for foo and bar. What if we don’t do the initialize and left foo and bar’s registry null? Should they get the attribute during serialization as well in this case? |
Actually that makes sense, it seems fine to avoid serializing the attribute if the registry is the same as the parent element.
So I think the serialization is somewhat non-trivial, and we should also carefully consider the possibility of some kind of "declarative custom element registry" in future, with that in mind I think we should go along some lines of:
Ideally we should have some story for global registry as a child of a scoped registry (??? in the table), as both it's not clear how to serialize it, and people transitioning to scoped registries will likely come across places where they need to opt-out. As a bikeshed perhaps just: <div customelementregistry="">
<x-foo></x-foo>
<div customelementregisty="global">
<x-foo></x-foo>
</div>
</div>Now in the chart I've put !!! in front of entries that, while all could be omitted, may have impacts on a possible future declarative custom element registries. e.g. If in future we have something like: <customelementregistry specifier="named">
<define>....</define>
</customelementregistry>
<div customelementregistry="named">
<div customelementregistry=""></div>
</div>then those entries with !!! may need special consideration for how it would interact with such a possible feature. |
||||||||||||||||||||
annevk
left a comment
There was a problem hiding this comment.
This attribute should also be in IDL.
I'm a bit less concerned about serialization, in particular about combinations you would only be able to end up with after performing tree mutations, such as a global registry child of a custom registry parent. I also don't want to go into the complexity of supporting values at this time as that would also raise questions for the equivalent declarative shadow root attribute.
The one bit of complexity is perhaps that we don't want to add the attribute redundantly I think. If we already serialized it for an ancestor there's no need to serialize it again.
| <span data-x="look up a custom element registry">looking up a custom element registry</span> | ||
| given <var>intendedParent</var>.</p></li> | ||
|
|
||
| <li><p>Let <var>keep registry null</var> be true if |
| "<code data-x="attr-crossorigin-use-credentials-keyword">use-credentials</code>"; | ||
| the empty string | ||
| <tr> | ||
| <th> <code data-x="">customelementregistry</code> |
|
If we don't want to over complex the serialization cases, should we consider keeping it to just whichever element has the attribute will get the attribute at serialization. Without considering tree mutation, the elements registry will only be global registry or null due to shadow root attribute/element attribute, and this could be reflected in serialization by serializing the attribute when it presents. |
|
I see the appeal, but I think I'd like to strike a balance where we make some effort to set it when we encounter a node that needs it (and doesn't already have it) and then ignore it for the remainder of that node's subtree. |
Introduce
customelementregistryglobal attribute for elements as discussed in whatwg/dom#1413(See WHATWG Working Mode: Changes for more details.)
/custom-elements.html ( diff )
/dom.html ( diff )
/index.html ( diff )
/indices.html ( diff )
/infrastructure.html ( diff )
/parsing.html ( diff )