Re: [webcomponents] On-demand custom elements using modules (#444)

> Rather, you should be able to use composable pieces like MutationObserver + the module loader to monitor for instances of a tag name and load modules with corresponding definitions on demand.

That's one option I'd considered, but doesn't cover elements created with `document.createElement()`.

> Even with your syntax, until the module loads you cannot create custom elements for those names. Your syntax is in fact worse since it gives you no way to know when the module loads, unlike System.import() (or whatever the loader spec ends up deciding on). 

That's not necessarily true for all cases (but for those cases, the custom element could dispatch a _"ready"_ event from its `createdCallback`), sometimes you need to do is something like this:

```javascript
let map = document.createElement('x-map'); // triggers module load
map.zoomLevel = 12;
map.long = -1.549077;
map.lat = 53.800755;
```

In that example, if `map` was inserted into the main document then the theoretical MO from your first point would trigger and load the module, but if it was inserted into another document or if it were appended to an element in a fragment it wouldn't.  This just seems like something that could be made much simpler by the specification.

---
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/444#issuecomment-197383230

Received on Wednesday, 16 March 2016 15:30:05 UTC