- From: Jeffrey Yasskin <notifications@github.com>
- Date: Mon, 25 Sep 2017 22:48:18 +0000 (UTC)
- To: whatwg/dom <dom@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/dom/issues/510/332035832@github.com>
If I understand correctly, @rniwa has a [2013 proposal](https://github.com/w3c/webcomponents/issues/135) to let Javascript write: ```js class FlagIcon extends HTMLElement { ... } customElements.define("flag-icon", FlagIcon, document.getElementById("flag-icon-template")); ``` which will auto-clone the template and make it the shadow root when a new `<flag-icon>` is created, and then the `FlagIcon` class can do what it wants with that shadow root. Then there's a [proposal from January](https://github.com/whatwg/html/issues/2254#issuecomment-272582982) to help libraries data-bind templates, with syntax, I think, like: ```js document.getElementById("flag-icon-template").createInstance({ field1: val1, field2: val2, }, (template, parts, params) => { return parts.forEach((part) => { eval(part); }) }); ``` (BTW, proposals in comment threads are really hard to understand. @rniwa, please create WICG repositories for this kind of thing so that we can see the current state of your thinking instead of having to trace its history and guess.) Those seem to fit together fairly well, since the `FlagIcon` class could provide the processor for the template picked by the third argument to `customElements.define()`. I'm not seeing how they help at all with the problem of injecting the contents of an element into its parent's shadow root. The interesting part of *this* problem is that you've written some HTML that you want to use as some particular element's shadow root, rather than as the shadow root of all elements with the same name, so the 2013 proposal isn't helpful. The HTML doesn't need data-binding, since it's written out literally, so the January proposal isn't helpful. Maybe I'm missing something. @rniwa, can you point that out? -- 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/510#issuecomment-332035832
Received on Monday, 25 September 2017 22:49:27 UTC