Skip to content

Instantly share code, notes, and snippets.

@AVGP
Created December 30, 2016 15:40
Show Gist options
  • Save AVGP/8fb1c740d44281a5a679d134e657b08b to your computer and use it in GitHub Desktop.
Save AVGP/8fb1c740d44281a5a679d134e657b08b to your computer and use it in GitHub Desktop.
<!doctype html>
<html>
<body>
<button is="plastic-button">Click Me!</button>
<script>
class PlasticButton extends HTMLButtonElement {
constructor() {
super()
let shadow = this.attachShadow({mode: 'open'})
let inner = document.createElement('div')
inner.textContent = 'It works!'
shadow.appendChild(inner)
this.addEventListener("click", () => {
console.log('Clicked!')
})
}
}
customElements.define("plastic-button", PlasticButton, { extends: "button" });
</script>
<button is="plastic-button">Test</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment