From 1868f38611e7d9b6e598036de129100bf5e98b6c Mon Sep 17 00:00:00 2001 From: Tim Branyen Date: Sun, 28 May 2017 19:16:37 -0700 Subject: [PATCH] Minimal implementation to HTMLElement interface --- lib/constructs/interface.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/constructs/interface.js b/lib/constructs/interface.js index 31ec915b..ff805f77 100644 --- a/lib/constructs/interface.js +++ b/lib/constructs/interface.js @@ -110,10 +110,22 @@ Interface.prototype.generateConstructor = function () { const passArgs = conversions.hasArgs ? ", args" : ""; this.str += ` iface.setup(this${passArgs}); +}\n`; + } else if (this.name === 'HTMLElement') { + this.str += `function ${this.name}() { + const { document, customElements } = global.window; + const ownerDocument = window.document[impl]; + let localName = null; + customElements[registry].forEach((Ctor, tagName) => { + if (this.constructor = Ctor) { + localName = tagName; + } + }); + module.exports.setup(this, arguments, { localName, ownerDocument }); }\n`; } else { this.str += `function ${this.name}() { - throw new TypeError("Illegal constructor"); + throw new TypeError('lol this is the DOM not JavaScript ya dummy'); }\n`; } @@ -132,6 +144,10 @@ Interface.prototype.generateRequires = function () { requireStr += `const impl = utils.implSymbol;\n`; + if (this.name === 'HTMLElement') { + requireStr += `const registry = utils.registrySymbol;\n`; + } + if (this.mixins.length !== 0) { requireStr += `const mixin = utils.mixin;\n`; for (let i = 0; i < this.mixins.length; ++i) {