Re: [w3c/webcomponents] HTML Modules (#645)

When reading the exports part I got super excited for a second but then I ran into the `<script>` tag. I think it would be super interesting to make "export by (HTML) id" the default. Then HTML imports could focus on being exactly HTML markup and it would be possible to cleanly split the code pieces:

```html
<!-- export myCustomElementTemplate -->
<template id="myCustomElementTemplate">
    <div class="myDiv">
        <div class="devText">Here is some amazing text</div>
    </div>
</template>
```

And the component lives in a simple `.js` file:

```js
import { myCustomElementTemplate as template } from './see-above.html';
 
class myCustomElement extends HTMLElement {
  constructor() {
    super();
    let shadowRoot = this.attachShadow({ mode: "open" });
    shadowRoot.appendChild(template.content.clone(true));
  }
}
window.customElements.define("myCustomElement", myCustomElement);
```

-- 
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/645#issuecomment-427417061

Received on Friday, 5 October 2018 16:06:08 UTC