[w3c/webcomponents] [declarative-custom-elements] how does the class get associated with the definition (#884)

In the following,

```js
<definition name="my-element">
    <template>....</template>
    <script type="module">
    class MyElement extends HTMLElement {
        #template;
        constructor(state, ...args) {
            super(state, ...args);
            #template = customElements.attachTemplateAsShadow(this, state);
        }
        render(state) {
            #template.update(state);
        }
    }
    </script>
</definition>
```

how does the engine know to define the `<my-element>` element using the `MyElement` class?

How does `type="module"` come into play here? What happens if type=module were not included?

What happens if I write two classes in the script tag? F.e.

```js
<definition name="my-element">
    <template>....</template>
    <script type="module">
    class MyElement extends HTMLElement {
        // ...
    }
    class MyOtherElement extends HTMLElement {
        // ...
    }
    </script>
</definition>
```

Or is the example in the proposal missing an `export`? Should it be

```js
<definition name="my-element">
    <template>....</template>
    <script type="module">
    export default class MyElement extends HTMLElement {
        // ...
    }
    </script>
</definition>
```

?

-- 
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/884

Received on Friday, 10 July 2020 17:24:10 UTC