-
Notifications
You must be signed in to change notification settings - Fork 378
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
defined promise #427
Comments
FWIW we've done something similar in Skate. The major use-case for us being that custom element upgrading can be erratic depending on when definitions are loaded and when the parser encounters them (elaborate explanation in the link). If you have a parent that needs to interact with a child, then you need a way to know when the child is upgraded. The other major use-case is what @jakearchibald mentioned which seems a result of |
I don't think this is a good idea since we shouldn't modify author-defined classes. It also doesn't make terribly much sense; if you have the class present, then you've probably already registered it. E.g. in your second example If I were to pick an API shape for this it'd be |
|
I'd prefer having document.customElements.define('my-element', MyElement);
document.customElements.check('my-element').then(~); |
If we're going to do that, we should do it soon. It would also be a good place to potentially stuff my An alternative is statics on HTMLElement. That might match reality better since these are not very document-scoped after all, as we discovered in #369. |
I started with a property on the instance (like Really not sure what I was thinking, putting the property on classes that clearly won't exist yet :/ |
So, this is pretty easy to add spec-wise. What is the implementer interest? @rniwa seemed vaguely supportive in #427 (comment) but I'd love to hear more of his opinion. @annevk, could you ask Gecko folks? @esprehn @kojiishi, any thoughts from Blink? @travisleithead, any thoughts from Edge? |
yeah, we think most components would like to wait for their dependencies to come in before instantiating/initializing themselves so having some feature to detect that seems useful. In terms of implementation, this is pretty trivial to implement unless I'm missing something. |
I think Mozilla is fine with this. Paging @smaug---- and @inscriber just in case. |
Not sure what the actual proposal is here, but sounds useful. Do we need to think about shadow dom here? I guess no, custom elements registry is currently global, which may not be quite right. (thinking about some closed shadow dom wanting to use some specific custom element but not expose that to outer world.) But that is a separate issue. |
Just that one; to check multiple at once you use
Hmm, that's a pretty interesting point (although I agree it's separate). People have talked about a registries API (#154 and elsewhere) but I hadn't considered if closed shadow roots give us new flexibility in that area. I guess we still have the problem that motivated us to make the registry per-global instead of per-document in the first place, which is that there's only one |
It looks useful to me too. @hayatoito |
I think Blink is fine with this. |
As discussed in WICG/webcomponents#427, this adds the ability for authors to wait for a given custom element name to become defined.
This has been specced in whatwg/html#1047 in case people want to review. |
As discussed in WICG/webcomponents#427, this adds the ability for authors to wait for a given custom element name to become defined.
Following from #425.
The
:defined
pseudo allows basic styling before an element becomes defined, such as reserving space for the element. However, that isn't always sufficient, and it feels like an extensible web violation to be able to react to upgrades via CSS but not via script.A property that resolves once an element is defined is a more extensible system.
Could/should this be a static property on the class?(edit: lol no)I don't want my element to be defined ahead of elements it uses in its shadow
I don't want to show an article until all custom elements have defined
The text was updated successfully, but these errors were encountered: