-->

Unregister custom element

2019-07-31 10:52发布

问题:

Is it possible to unregister a custom element that has been created by createCustomElement?

We use Web Components to wrap out vertical features, all 'parts' of the feature are downloaded before the Web Component is added to the DOM.

What we would really like is to completely destroy the component when the feature is no longer active but there it looks like there is no API available.

Has anyone had any luck with this?

回答1:

At the Angular level, there doesn't seem to be any "destroy" or "remove" function alongside createCustomElement in @angular/elements.

At the DOM level, looking at the CustomElementRegistry interface, the interface provided by customElements, there is no "undefine" or similar to accompany define. (This may be part of why Angular doesn't have a "destroy" or "remove"...)

So I'd say: No, you can't remove it.