Composants
Le concept
Custom Elements
/* The custom element definition. */
class HelloElement extends HTMLElement {
connectedCallback() {
this.textContent = 'Hello 🌍';
}
}
/* Registering the custom element. */
customElements.define('wt-hello', HelloElement);
/* Injecting the element using innerHTML... */
document.body.innerHTML = '<wt-hello></wt-hello>';
/* ... or using appendChild & createElement. */
document.body.appendChild(document.createElement('wt-hello'));Custom Elements & Web Components Tooling
Separation of Concerns
Isolement
Mis à jour