Re: [w3c/webcomponents] Declarative syntax for custom elements (#136)

I think a neat way of doing this is allowing people to send a `document-fragment`as a property of the `define` method’s `options` argument.

```HTML
<!doctype html>
<html>
 <head>
  <template id="foo" data-custom>foo</template>
  <template id="bar" data-custom>bar</template>
  <template id="baz" data-custom>baz</template>
  <script>
   for(let template of Array.from(document.head.querySelectorAll("template[data-custom]")))
   {
    document.define("x-" + template.id, class extends HTMLElement {}, {template: template.content });
   }
  </script>
 </head>
 <body>
  <x-foo></x-foo>
  <x-bar></x-bar>
  <x-baz></x-baz>
 </body>
</html>
```
Then, when created, `x-foo`s would all have an immutable shadow root. When promoted, `x-foo`s would discard their shadow roots (if they have any) and gain a new immutable one.


---
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/136#issuecomment-225251049

Received on Friday, 10 June 2016 17:55:36 UTC