Created
February 9, 2019 09:38
-
-
Save alejandrolechuga/4756d862300e15d23723fb7b9ccfe135 to your computer and use it in GitHub Desktop.
Extend from proto
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
/* 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