Skip to content

Instantly share code, notes, and snippets.

@mistyharsh
Last active April 7, 2019 10:49
Show Gist options
  • Save mistyharsh/1f3c9388854044b28d78e443a1e81a34 to your computer and use it in GitHub Desktop.
Save mistyharsh/1f3c9388854044b28d78e443a1e81a34 to your computer and use it in GitHub Desktop.
class FancyComponent extends HTMLElement {
constructor() {
super();
const shadowRoot = this.attachShadow({ mode: 'open' });
shadowRoot.innerHTML = `
<!-- Styles are scoped -->
<style>
p { color: red; }
</style>
<div>
<p>Hello World</p>
</div>
`;
}
}
customElements.define('fancy-comp', FacyComponent);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment