diff --git a/lib/polyfills.js b/lib/polyfills.js index b7fc44e..65d71a2 100644 --- a/lib/polyfills.js +++ b/lib/polyfills.js @@ -405,24 +405,22 @@ exports.Element_attachShadow = jss` } rel.call(target, type, listener, options); } - function sanityChecks(a, name, cls) { - const namDef = a.a.get(name), - clsDef = a.g.get(cls); - console.dir({ - _name: name, - _cls: cls, - regName: namDef, - regCls: clsDef, - sameConstrName: (namDef?namDef.constructorFunction==cls:undefined), - sameConstrClass: (clsDef?clsDef.constructorFunction==cls:undefined), - }); - } customElements.define = function (name, cls) { asNames.add(name); - sanityChecks(customElements.a, name, cls); cls.prototype.addEventListener = addCEEventListener; cls.prototype.removeEventListener = removeCEEventListener; - oldCED.call(customElements, name, cls); + try { + return oldCED.call(customElements, name, cls); + } catch(c) { + // rewrite JS exception classes from polyfill to correct DOMException + if (c instanceof SyntaxError) { + throw new DOMException(c.message, "SyntaxError"); + } else + if (c instanceof Error && c.name==="Error") { + throw new DOMException(c.message, "NotSupportedError"); + } else + throw c; + } }; } }())`;