Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove or unregister a registered Custom Element?

I'm currently testing the performance of Custom Elements, so I stumpled upon the need to unregister a previously registered element. I couldn't find anything about that.

I think that could probably be needed, but before I have not researched this problem in more detail I'll not do any assumptions.

I know I could do it with refreshing the page, but that's not the point here.

What I've done so far to register an element the native, spec-like way:

document.registerElement('my-element', {
    prototype: Object.create(HTMLElement.prototype)
});
like image 320
Patrick Hillert Avatar asked Nov 21 '14 09:11

Patrick Hillert


People also ask

Can custom elements be self closing?

Custom elements cannot be self-closing because HTML only allows a few elements to be self-closing. Always write a closing tag ( <app-drawer></app-drawer> ).

What is a custom element?

Custom Elements allow web developers to define new types of HTML elements. The spec is one of several new API primitives landing under the Web Components umbrella, but it's quite possibly the most important. Web Components don't exist without the features unlocked by custom elements: Define new HTML/DOM elements.

What are autonomous custom elements?

Autonomous custom elements are new HTML tags, defined entirely by the author. They have none of the semantics of existing HTML elements, so all behaviors need to be defined by the author. Customized built-ins extend existing HTML elements with custom functionality. They inherit semantics from the elements they extend.

What is CustomElementRegistry?

The CustomElementRegistry interface provides methods for registering custom elements and querying registered elements. To get an instance of it, use the window. customElements property.


1 Answers

There is one or two discussions on google groups about unregistering elements but as far as I know no solution so far. https://groups.google.com/forum/#!topic/polymer-dev/31W69ZE1Wng

like image 155
sesteva Avatar answered Oct 11 '22 05:10

sesteva