Friends,
I have created custom element with shadow dom.
class RamElementE extends HTMLElement {
static get observedAttributes(){return ["label"];}
constructor(){ super();
this.attachShadow({mode:"open"});
this.input = document.createElement("input
");this.label = document.createElement("label");this.input.id="me";
this.button = document.createElement("button");this.button.textContent="∆";
this.shadowRoot.appendChild(this.input); this.shadowRoot.appendChild(this.label);this.shadowRoot.appendChild(this.button);
}
attributeChangedCallback(name,oldVal,newVal){if(name === 'label' && newVal){this.label.textContent = newVal;this.button.textContent=newVal;}}
}
customElements.define("ram-element-e",RamElementE);
Comments