Created
February 5, 2020 15:04
-
-
Save enjikaka/c91aaa027fc8105a6c70d4be3ffb71cc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default class TidalWebComponent extends HTMLElement { | |
static css (strings) { | |
const text = strings.raw.join(); | |
const sheet = new CSSStyleSheet(); | |
sheet.replace(text); | |
return sheet; | |
} | |
static html (strings) { | |
const text = strings.raw.join(); | |
const frag = document.createRange().createContextualFragment(text); | |
return frag; | |
} | |
connectedCallback () { | |
this._sDOM = this.attachShadow({ mode: 'closed' }); | |
const css = this.css; | |
if (css) { | |
this._sDOM.adoptedStyleSheets = [this.css]; | |
} | |
const html = this.html; | |
if (html) { | |
this._sDOM.appendChild(html); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment