CustomElementRegistry.upgrade() - оновлює елементи в користувацькому елементі.
customElements.upgrade( root );
customElements - об'єкт CustomElementRegistry.
root - елемент який потрібно оновити.
upgrade() метод об'єкта CustomElementRegistry який оновлює елементи в користувацькому елементі.
<my-component></my-component>
class MyComponent extends HTMLElement{
constructor(){
super();
var shadow=this.attachShadow({mode:'open'});
var label=document.createElement('label');
label.innerText='Ім\'я: ';
shadow.appendChild(label);
var input=document.createElement('input');
shadow.appendChild(input);
}
};
customElements.define('my-component', MyComponent);
setTimeout(function(){console.log('upgrade');
var el=document.querySelector('my-component');
customElements.upgrade(el);}, 5000);