webcomponents / webcomponents.org

Home of the web components community
https://www.webcomponents.org
Apache License 2.0
359 stars 95 forks source link

how to unregister a custom element #1294

Closed mohamedafzal03 closed 1 year ago

mohamedafzal03 commented 3 years ago

Origin page HI to register a custom element, window.customElements.define('my-custom-element', MyCustomElement); I want to unregister a custom element , is there any possibilities? like(window.customElements.undefine('my-custom-element') will be helpful if u guys share your insights.

jogibear9988 commented 2 years ago

this is not possible at the moment. maybe this would help in the future: https://github.com/webcomponents/polyfills/tree/master/packages/scoped-custom-element-registry

If you'd like to replace a registered component, you could register a proxy wich then later could replace the implementation.

justinfagnani commented 1 year ago

This is a spec question. It's currently impossible to unregister an element (and there are questions about what that would mean). You can see the spec issue here: https://github.com/WICG/webcomponents/issues/754