- From: Nolan Lawson <notifications@github.com>
- Date: Wed, 10 Jan 2024 11:44:19 -0800
- To: WICG/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <WICG/webcomponents/issues/1043/1885596016@github.com>
@justinfagnani Your code example may be a bit contentious for framework authors, since I imagine it would tank `js-framework-benchmark` performance (due to having to look up the `rootNode` for every `createElement`/`<template>` clone)… Although maybe it could be mitigated by only running `getRootNode` for custom elements (e.g. search the tag name for a hyphen). > Just to clarify, I believe in general if there is no global definition, you won't have to use ShadowRoot.createElement. This is because the element will follow the rules of custom element upgrade, meaning it will upgrade when it's attached to the DOM (as long as it's :not(:defined) at that point). @sorvell This is an interesting solution. I think it might actually solve our use case, since there is no chance that `document.createElement('x-foo')` would give you a `FooComponent` that doesn't "belong" to you. (You would need access to a `shadowRoot` to get access to the scoped custom element definition.) The downside is that you wouldn't be able to have _any_ top-level custom elements, unless you are willing to expose them globally (to disconnected `createElement`s). In our case, we would probably have to have some kind of dummy `<x-app>` top-level component that doesn't do anything except encapsulate the whole thing. But maybe that's okay, since script can do `document.body.querySelectorAll('*')` anyway and get access to those top-level constructors. -- Reply to this email directly or view it on GitHub: https://github.com/WICG/webcomponents/issues/1043#issuecomment-1885596016 You are receiving this because you are subscribed to this thread. Message ID: <WICG/webcomponents/issues/1043/1885596016@github.com>
Received on Wednesday, 10 January 2024 19:44:26 UTC