Skip to content

Instantly share code, notes, and snippets.

@rarous
Created October 14, 2024 17:06
Show Gist options
  • Save rarous/b4dff9466392bb05ea1aea4fad857a48 to your computer and use it in GitHub Desktop.
Save rarous/b4dff9466392bb05ea1aea4fad857a48 to your computer and use it in GitHub Desktop.
Isomorphic Web Component definition Live Template for Webstorm
/**
* @param {Window} globalScope
* @return {typeof $NAME$}
*/
export function def$NAME$({ HTMLElement, customElements }) {
class $NAME$ extends HTMLElement {
static register(tagName = "$TAG$") {
this.tagName = tagName;
customElements.define(tagName, this);
}
connectedCallback() {
$END$
}
}
return $NAME$;
}
if (globalThis.window?.customElements) {
def$NAME$(window).register();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment