Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom element definition to be 'changed' #10063

Open
jakearchibald opened this issue Jan 15, 2024 · 3 comments
Open

Allow custom element definition to be 'changed' #10063

jakearchibald opened this issue Jan 15, 2024 · 3 comments
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest topic: custom elements Relates to custom elements (as defined in DOM and HTML)

Comments

@jakearchibald
Copy link
Collaborator

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:

  • For existing elements, constructors are not re-run when updating a class.
  • For existing elements, newly added fields/properties are not available.
  • A web component's observedAttributes list cannot be updated over time. Updates require a refresh.

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

@jakearchibald jakearchibald added addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest labels Jan 15, 2024
@smaug----
Copy link
Collaborator

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

@annevk
Copy link
Member

annevk commented Jan 15, 2024

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

@annevk annevk added the topic: custom elements Relates to custom elements (as defined in DOM and HTML) label Jan 15, 2024
@jakearchibald
Copy link
Collaborator Author

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements needs implementer interest Moving the issue forward requires implementers to express interest topic: custom elements Relates to custom elements (as defined in DOM and HTML)
Development

No branches or pull requests

3 participants