Skip to content

Instantly share code, notes, and snippets.

@Happy-Ferret
Forked from hemanth/es6-dom-extend.js
Created March 17, 2017 10:00
Show Gist options
  • Save Happy-Ferret/2f190b715376fc6b0858ccb65e0cdec1 to your computer and use it in GitHub Desktop.
Save Happy-Ferret/2f190b715376fc6b0858ccb65e0cdec1 to your computer and use it in GitHub Desktop.
Extend DOM elements ES6
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