- From: Mason Freed <notifications@github.com>
- Date: Mon, 23 Nov 2020 15:02:22 -0800
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Monday, 23 November 2020 23:02:35 UTC
I'm thinking that given the issues here, it might be best to just **not** add a `setInnerHTML()` type API at this point, and leave `DOMParser` as the only fragment parser entry point that (optionally) accepts declarative Shadow DOM. We can always add a `setInnerHTML()` type capability later, if it turns out to be a key use case. Given that the primary motivating use case for declarative Shadow DOM is SSR, which doesn't need an imperative interface at all, perhaps that's not too much of a limitation. It also seems like it could be relatively easily polyfilled: ```javascript Element.prototype.setInnerHTML = function(content) { const fragment = (new DOMParser()).parseFromString(`<pre>${content}</pre>`, 'text/html', {includeShadowRoots: true}); this.replaceChildren(...fragment.body.firstChild.childNodes); }; ``` I'm going to move forward with this approach for now, but please feel free to chime in with comments. -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/whatwg/dom/issues/912#issuecomment-732476002
Received on Monday, 23 November 2020 23:02:35 UTC