Last active
November 15, 2024 15:57
-
-
Save hemanth/e6bb66141101b52a76fe to your computer and use it in GitHub Desktop.
Extend DOM elements ES6
This file contains 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() | |
*/ |
NookieGrey
commented
Oct 16, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment