Skip to content

Instantly share code, notes, and snippets.

@Comandeer
Last active August 27, 2018 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Comandeer/647933febb396ab6d11ba19d685c2926 to your computer and use it in GitHub Desktop.
Save Comandeer/647933febb396ab6d11ba19d685c2926 to your computer and use it in GitHub Desktop.
UnityComponent class
function registerComponent( { template, style, script } ) {
class UnityComponent extends HTMLElement {
connectedCallback() {
this._upcast();
}
_upcast() {
const shadow = this.attachShadow( { mode: 'open' } );
shadow.appendChild( style.cloneNode( true ) );
shadow.appendChild( document.importNode( template.content, true ) );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment