Unregister custom element

2019-07-31 10:24发布

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条回答
兄弟一词,经得起流年.
2楼-- · 2019-07-31 11:18

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.

查看更多
登录 后发表回答