-
Notifications
You must be signed in to change notification settings - Fork 376
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 customElements.upgrade
#710
Comments
Also see #419 (comment) |
Additional thought: If we get something like We've had various requests for controlling upgrades come in from customers, but @sorvell would have more detail. |
Argh, let's not scope-creep this, or it won't happen :(. We already have to figure out deep vs. not... |
I think deep makes more sense than shallow. It's almost never useful to upgrade just the root and not its descendent. |
Is there actually a use case for shallow even? |
@bkardell @rniwa is there any way you can provide a code sample of shallow vs deep? https://github.com/devpunks/snuggsi/blob/master/custom-element-registry/index.es#L30-L45 Just trying to understand if you mean the following: <foo-bar>
<baz-bat>Who is responsible for my upgrade?</baz-bat>
</foo-bar> |
@snuggs the method is given a node. The question is then whether you just upgrade that node, or that node and also all its descendants. So with your example, if you pass in |
@annevk Thanks for the clarity! Ran into this use case with a client. The use case was
What worked was wherever the script is declared (pre/post body) the algo is this:
3 is where the specs would usually 💥 but we were more lackadaisical. To be clear this isn't an encouragement towards the spec. More trying to abide with implementation aligned as close to what we are doing here while underlying vendor implementation evolves. Super looking forward to movement in this space. Many of these problems have been solving for the past year or two. Love seeing this be revisited. |
https://bugs.webkit.org/show_bug.cgi?id=183397 Reviewed by Frédéric Wang. LayoutTests/imported/w3c: Rebaseline the test now that we're passing. * web-platform-tests/custom-elements/custom-element-registry/upgrade-expected.txt: Source/WebCore: Added the support to upgrade custom elements directly. Ordinarily, custom elements get upgraded as they are inserted / connected into a document but some script libraries and authors want to be able to upgrade them before that. Also see WICG/webcomponents#710 Implemented the method as specified at: https://html.spec.whatwg.org/multipage/custom-elements.html#dom-customelementregistry-upgrade When invoked, the upgrade(root) method must run these steps: 1. Let candidates be a list of all of root's shadow-including inclusive descendant elements, in shadow-including tree order. 2. For each candidate of candidates, try to upgrade candidate. Tests: imported/w3c/web-platform-tests/custom-elements/custom-element-registry/upgrade.html * dom/CustomElementReactionQueue.cpp: (WebCore::CustomElementReactionQueue::enqueueElementUpgradeIfDefined): Removed the assertion that the upgraded element is connected since the whole point of this API is to upgrade a disconnected element. * dom/CustomElementRegistry.cpp: (WebCore::upgradeElementsInShadowIncludingdescendants): Added. (WebCore::CustomElementRegistry::upgrade): Added. * dom/CustomElementRegistry.h: Forward declare DeferredPromise instead of unnecessarily including JSDOMPromiseDeferred.h. * dom/CustomElementRegistry.idl: * dom/Element.cpp: (WebCore::Element::insertedIntoAncestor): Moved the assertion here. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@234507 268f45cc-cd09-0410-ab3c-d52691b4dbfc
https://bugs.webkit.org/show_bug.cgi?id=183397 Reviewed by Frédéric Wang. LayoutTests/imported/w3c: Rebaseline the test now that we're passing. * web-platform-tests/custom-elements/custom-element-registry/upgrade-expected.txt: Source/WebCore: Added the support to upgrade custom elements directly. Ordinarily, custom elements get upgraded as they are inserted / connected into a document but some script libraries and authors want to be able to upgrade them before that. Also see WICG/webcomponents#710 Implemented the method as specified at: https://html.spec.whatwg.org/multipage/custom-elements.html#dom-customelementregistry-upgrade When invoked, the upgrade(root) method must run these steps: 1. Let candidates be a list of all of root's shadow-including inclusive descendant elements, in shadow-including tree order. 2. For each candidate of candidates, try to upgrade candidate. Tests: imported/w3c/web-platform-tests/custom-elements/custom-element-registry/upgrade.html * dom/CustomElementReactionQueue.cpp: (WebCore::CustomElementReactionQueue::enqueueElementUpgradeIfDefined): Removed the assertion that the upgraded element is connected since the whole point of this API is to upgrade a disconnected element. * dom/CustomElementRegistry.cpp: (WebCore::upgradeElementsInShadowIncludingdescendants): Added. (WebCore::CustomElementRegistry::upgrade): Added. * dom/CustomElementRegistry.h: Forward declare DeferredPromise instead of unnecessarily including JSDOMPromiseDeferred.h. * dom/CustomElementRegistry.idl: * dom/Element.cpp: (WebCore::Element::insertedIntoAncestor): Moved the assertion here. Canonical link: https://commits.webkit.org/203374@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234507 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Hello @justinfagnani, |
@GeorgeTailor We don't have a specific separate issue that I know of, though the idea of batched definitions came up briefly in the scoped custom element registry discussions. Note that batching won't have any impact on multiple instances of the same definition - it might have an impact on many separate definitions though by avoiding multiple tree walks. |
Filed #922. Please continue the discussion there of using this closed issue for adding |
We need a mechanism to trigger an upgrade on a disconnected tree of nodes per in-persion discussions with @domenic and @justinfagnani
The text was updated successfully, but these errors were encountered: