New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Illegal constructor on Safari #8
Comments
Error occurs here after observer detected the
So it looks like it is forbidden to instantiate an
I must be missing something essential. |
It looks that the script alternative triggers another part of the polyfill which doesn't fail in this case: var _override = null;
getOwnPropertyNames(self).filter(function (k) {
return /^HTML/.test(k);
}).forEach(function (k) {
var HTMLElement = self[k];
function HTMLBuiltIn() { <== MyComponent.super() calls this
var constructor = this.constructor;
if (!_classes.has(constructor)) throw new TypeError('Illegal constructor');
var _classes$get = _classes.get(constructor),
is = _classes$get.is,
tag = _classes$get.tag;
if (is) {
if (_override) return _augment(_override, is); <== works down here
var element = _createElement.call(document$1, tag);
element.setAttribute('is', is);
return _augment(setPrototypeOf(element, constructor.prototype), is);
} else return construct.call(this, HTMLElement, [], constructor);
}
defineProperty(HTMLBuiltIn.prototype = HTMLElement.prototype, 'constructor', {
value: HTMLBuiltIn
});
defineProperty(self, k, {
value: HTMLBuiltIn
});
}); |
beside the fact this polyfill works already, this issue is missig how and/or when you import the polyfill, and the SO issue (nobody mentioned me in there, how can I even help?!?) is also importing a default, as if this module actually export anything at all. So ...
|
Indeed this was an import order issue. Doing:
fails, but doing:
works. Thanks for the hint! |
@Javarome for what is worth it as a hint, every single polyfill should always be loaded before anything else ... we (polyfils authors) can't fight the unknown all libraries internals do, so bring the polyfill always before everything else and code happily ever after 🥳 |
I'm using the polyfill to use built-in web components on Safari, which works fine when using:
However when using it as an imported package, I get the following error at component's creation (not explicit creation through JS, but implicit through the element in HTML code).
Component's code is basically:
Notes:
import "@ungap/custom-elements"
. At runtime it is there and executed, and the component has been property registered (usingwindow.customElements.define("my-input", MyComponent, {extends: "input"})
) as the error occurs in the polyfill code ;The text was updated successfully, but these errors were encountered: