Domenic Denicola d at
Fri Aug 21 15:12:03 UTC 2015

From: es-discuss [mailto:es-discuss-bounces at] On Behalf Of James Burke

> In the spirit of the extensible web, defining these lower level APIs and more
> of the loader would make it possible to use custom elements to help
> prototype a <module> tag. The custom element mechanism can be used in a
> similar way to how JS transpilers are used for the existing module syntax.

No, custom elements cannot prototype the module tag, because custom elements will always be parsed as unknown elements. So e.g.

const stuff = "<p>Stuff</p>";

will be parsed as

|- text node: const stuff = "
|- p
|---- text node: Stuff
| - text node: ";

and of course it gets much worse if you use any elements that do something visual or interesting, like `<img>` or `<custom-module>` or `<script>`.

This is why we need to use an existing parsed-as-is element (namely `<script>`, although I guess we could maybe make `<style>` work in a pinch), and why custom elements won't work.

More information about the es-discuss mailing list