Skip to content

Instantly share code, notes, and snippets.

@alejandrolechuga
Created February 9, 2019 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alejandrolechuga/4756d862300e15d23723fb7b9ccfe135 to your computer and use it in GitHub Desktop.
Save alejandrolechuga/4756d862300e15d23723fb7b9ccfe135 to your computer and use it in GitHub Desktop.
Extend from proto
/* jshint esnext: true */
function Element(tipo) {
this.element = document.createElement(tipo);
}
Element.prototype.destroy = function(){
var parent = this.element.parentNode;
parent.removeChild(this.element);
this.element = null;
}
Element.prototype.html = function (){
return this.element;
}
class Input extends Element {
constructor(label) {
super('input');
}
}
var input = new Input();
document.body.appendChild(new Input().html())
input.destroy();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment