WebReflection / document-register-element

A stand-alone working lightweight version of the W3C Custom Elements specification
ISC License
1.13k stars 116 forks source link

TypeError - Object doesn't support property or method 'registerElement' #180

Closed dnicolson closed 4 years ago

dnicolson commented 4 years ago

I have noticed with version 1.14.3 for some browsers the registerElement method does not exist at times.

On Firefox (at least versions 38/52/55/60) the following minified error appears: TypeError - l[y] is not a function document[REGISTER_ELEMENT]

On various Windows phones (IEMobile/11.0) the following error appears: TypeError - Object doesn't support property or method 'registerElement'

It appears to be related to the last IE11 fix (https://github.com/WebReflection/document-register-element/issues/175), specifically this change as version 1.14.2 does not appear to be affected. The custom elements do not exist in iframes.

Unfortunately, these are only errors in production and I cannot reproduce the issue myself to provide an example. The errors occurred frequently in production with 1.14.3 so I am reasonably confident 1.14.2 fixes the problem.

WebReflection commented 4 years ago

are you somehow preventing the iframe/page to reload?

that change is needed otherwise refreshed iframes would fail.

However, if you are confident with 1.14.2 you don't have issues, and as this cannot be feature detected, I suggest you stick with 1.14.2.

This library is basically maintenance mode only, but also people should stop using the dead V0 API.

customElements.define is what everyone should use already.

dnicolson commented 4 years ago

No iframes are used, 1.14.2 is a solid release.

I created the issue in the hope that others would see it. Thanks for you work!

WebReflection commented 4 years ago

No iframes are used

There's only a scenario where you can have issue: users tries to leave the page but you warn them not to, and they don't leave the page.

In such scenario, beforeunload might have triggered already, but I can't possibly know if there were other listeners in there, so the only thing I think I could do, is to eventually re-attach those methods within a setTimeout, which hopefully will execute only if the user didn't close the page, otherwise we'd be back with the IE11 issue.

I'll play with that, and see how that goes. It's not perfect, but I think it might practically works.