italia2024
Version:
Italia 2024 assets
32 lines (28 loc) • 806 B
JavaScript
(function () {
//CustomElement: ❬meric❭ の定義
class Meric extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' }); //シャドウDOMを使用して内部構造を隠す
//スタイルを適用
this.shadowRoot.innerHTML = `
<style>:host {
display: inline-flex;
justify-content: center;
align-items: center;
}</style>
`;
}
static get observedAttributes() {
return ['style', 'class']; //属性変更時のメソッド
}
attributeChangedCallback(name, oldValue, newValue) {
if (name === 'style') {
this.style.cssText = newValue;
} else if (name === 'class') {
this.className = newValue;
}
}
}
customElements.define("meric", Meric);
})(); ///function:CustomElement: ❬spacer /❭;