diff --git a/index.js b/index.js index e69de29..547f035 100644 --- a/index.js +++ b/index.js @@ -0,0 +1,47 @@ +// Demonstrate polymorphism. +function HtmlElement() { + this.click = function() { + console.log('click'); + } +} + +HtmlElement.prototype.focus = function() { + console.log('focus'); +} + +// Select Element. +function HtmlSelectElement(items = []) { + this.items = items; + + this.addItem = function(item) { + this.items.push(item); + } + + this.removeItem = function(item) { + this.items.pop(item); + } + + this.render = function() { + let selectHtml = ''; + return selectHtml; + } +} + +HtmlSelectElement.prototype = new HtmlElement(); +HtmlSelectElement.prototype.constructor = HtmlSelectElement; + +// Image Element. +function HtmlImageElement(src = 'https://image') { + this.src = src; + + this.render = function () { + return ``; + } +} + +HtmlImageElement.prototype = new HtmlElement(); +HtmlImageElement.prototype.constructor = HtmlImageElement;