Re: [WICG/webcomponents] Lazy Custom Element Definitions (#782)

> Why not just have an event that fires whenever an unknown element appears? Then I can do whatever I want with that information.

I could get behind an event if we had a way to query the registry for unregistered elements already on the page. Without that, an event would require a discovery method and DOM traversal to find elements added before the listener.

I like the ergonomics of @justinfagnani’s initial post. Pre-registering and offloading the import mechanism to the user would satisfy all the use cases I currently have for this feature.

Related: I recently built an auto loader for Shoelace using a mutation observer. It has a similar problem in that it requires an initial discovery method that runs since I can’t guarantee the auto loader initializes before custom elements are in the DOM.

A promise-based syntax makes auto loading trivial, as long as the list of tag names are known ahead of time. That said, there still could be a gap for unknown elements that events would solve. But again, we’d need a low cost way to query for unregistered elements in a document for this to be a complete solution.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/WICG/webcomponents/issues/782#issuecomment-1524157095
You are receiving this because you are subscribed to this thread.

Message ID: <WICG/webcomponents/issues/782/1524157095@github.com>

Received on Wednesday, 26 April 2023 23:10:59 UTC