CustomElementRegistry

CustomElementRegistry об'єкт для реєстрації елементів користувача.

Синтаксис:

window.customElements;

Параметри:

window - не обов'язково вказувати. Об'єкт window.

Опис:

CustomElementRegistry об'єкт для реєстрації елемента користувача.

Це дозволяє створювати Web-компоненти.

Приклад:

<my-component></my-component> class MyComponent extends HTMLElement{ constructor(){ super(); this.input=document.createElement('input'); this.input.addEventListener('input', function(){ this.parentElement.label.innerText=this.value; }); this.appendChild(this.input); this.label=document.createElement('label'); this.appendChild(this.label); } } customElements.define("my-component", MyComponent);