trying out webcomponents but have gotten to a error I dont get.
The markup is simple and should work. 2 files, both are html files.
the error is marked on the <script>
tag on in the console.
Thanks for any assistance.
PS. I am running Google Chrome Beta to get the customElements to work.
km-button.html
<script>
class KmButton extends HTMLButtonElement {
constructor() {
super();
}
}
customElements.define('km-button', KmButton, {extends: 'button'});
</script>
index.html
<!DOCTYPE html>
<html>
<head>
<!-- import webcomponents -->
<link rel="import" href="./components/km-button.html">
</head>
<body>
<km-button>hej</km-button>
</body>
</html>
Error
km-button.html:1 Uncaught TypeError: Illegal constructor(…)KmButton @ km-button.html:7
Actually it still does't work (after your corrections).
AFAIK the extends
feature is not implemented yet in Custom Elements v1 for Chrome.
So the is=
syntax is simply (and silently) ignored and your button is viewed as a standard <button>
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With