Introduce customelementregistry global attribute#12000
Introduce customelementregistry global attribute#12000ja-y-son wants to merge 3 commits intowhatwg:mainfrom
Conversation
|
@annevk Here's the PR for the new custom element registry attribute. |
|
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.
|
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. |
- Fix typos: data-x-fref -> data-x-href, elemenet -> element - Fix indentation in attributes table - Rename variable keep registry null to keepRegistryNull - Add customElementRegistry IDL attribute to HTMLElement interface - Add serialization steps for customelementregistry attribute Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Apologies for dropping the ball on this one. I’ve addressed the comments, and regarding the serialization, I think a balanced approach would be to serialize the attribute at the boundary of a registry change, as outlined in the PR. Would love to get feedback and get things rolling again :) |
|
Also added WPT coverage on the new global attribute in this PR |
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 )