whatwg / html

HTML Standard
https://html.spec.whatwg.org/multipage/
Other
7.85k stars 2.57k forks source link

Allow custom element definition to be 'changed' #10063

Open jakearchibald opened 5 months ago

jakearchibald commented 5 months ago

What problem are you trying to solve?

Over in frameworks land, hot module replacement allows development servers to seemingly apply changes made in the editor directly onto the the active page, without a refresh, and without losing current state.

This is impossible with web components, because once a component is defined, it's forever-defined. In particular, things like observedAttributes cannot be changed.

What solutions exist today?

https://open-wc.org/docs/development/hot-module-replacement/, but it notes the following limitations:

How would you solve it?

Being able to programatically 'undefine' a custom element, allowing it to be re-defined with a new class, would solve the limitations encountered by open-wc.

Anything else?

No response

smaug---- commented 5 months ago

So would undefining go through the existing custom elements and change the prototype and even remove shadow DOM, or what?

annevk commented 5 months ago

This is a duplicate of https://github.com/WICG/webcomponents/issues/820, but maybe it's useful to track it in multiple places. As Olli indicates, having something more concrete to evaluate would help.

jakearchibald commented 5 months ago

@smaug----

So would undefining go through the existing custom elements and change the prototype and even remove shadow DOM, or what?

Yeah, my feeling is it would revert the prototypes to HTMLElement. Obviously any shadow DOM etc left behind would still be there.

@annevk yeeeeeep, this is a dupe. Forgot to check that repo.