- From: Mason Freed <notifications@github.com>
- Date: Thu, 26 Mar 2020 16:22:35 -0700
- To: w3c/webcomponents <webcomponents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/webcomponents/issues/871/604736518@github.com>
Thanks @JanMiksovsky for opening this issue. It seems that there are two relevant potential use cases here: 1. Existing components, built without knowledge of declarative Shadow DOM. These call `this.attachShadow()` and assume a. it does not throw, and b. it returns an empty shadow root. It then fills the shadowroot with shadow content. 2. Components that are built with knowledge of declarative Shadow DOM, and that wish to use a closed shadow root. In this case, the component will want to retrieve the existing (closed) shadowRoot so that it can verify the content and/or hook up events and references. It does not want to blow away and re-create existing declarative content. It would seem that the most clean API to address both cases above would be: 1. For use case #1, make `attachShadow()` blow away any existing **declaratively-created** shadow root, and return a new, empty shadowroot. (Alternatively, this could delete the existing contents of the shadowroot, and return a reference to the existing shadowroot.) 2. For use case #2, add a `shadowRoot` accessor to `ElementInternals`, to allow "declarative aware" components to retrieve their closed shadow root. Alternatively, *an extra argument* could be added to attachShadow() which causes it to retrieve the existing shadow root *without* removing its contents. Either would seem to achieve the goal. Though `ElementInternals.shadowRoot` does seem considerably better, ergonomically. @justinfagnani, I could imagine a framework that simply renders all content server-side, and then calls `getInnerHTML()` to retrieve the declarative content to send down to the client. In this case, the component and the framework would not need to "coordinate", and you could then get use case #1 above that wakes up with declarative content but doesn't know how to deal with it. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/w3c/webcomponents/issues/871#issuecomment-604736518
Received on Thursday, 26 March 2020 23:22:48 UTC