-
-
Save Happy-Ferret/2f190b715376fc6b0858ccb65e0cdec1 to your computer and use it in GitHub Desktop.
Extend DOM elements ES6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SmartButton extends HTMLButtonElement { | |
constructor() {} | |
} | |
let sb = new SmartButton(); | |
document.body.appendChild(sb); | |
/* | |
I get the below error: | |
TypeError: Failed to execute 'appendChild' | |
on 'Node': parameter 1 is not of type 'Node'. | |
It needs a document.registerElement as well? :/ | |
But then what's the whole point of extending, it can just do a Object.create() | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment