Skip to content
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

Custom elements issue with x_ite.mjs in Microsoft Edge? #159

Closed
gwhitney opened this issue Oct 9, 2023 · 3 comments
Closed

Custom elements issue with x_ite.mjs in Microsoft Edge? #159

gwhitney opened this issue Oct 9, 2023 · 3 comments

Comments

@gwhitney
Copy link
Contributor

gwhitney commented Oct 9, 2023

Is there a problem with x_ite.mjs in the Microsoft Edge browser? I ask because my Firefox extension is now working as mentioned in #155, and so I am trying to get it to work on Microsoft Edge as well. I put in the browser polyfill as recommended at https://github.com/mozilla/webextension-polyfill, and all of the other code of my plugin appears to work until it actually loads x_ite.mjs for the first time. At that point, it crashes with an error of Uncaught (in promise) TypeError: Cannot read properties of null (reading 'define') in this line of code:

customElements .define ("x3d-canvas", x_ite_X3DCanvasElement);

in the (bundled version of ) src/x_ite.js. Thus, it appears as if customElements was not defined, but if I just type customElements in the console on that page, it seems to have a perfectly reasonable value. So somehow maybe it's just not defined in the context in which that module is executed in my extension? I generally don't develop on Windows -- I don't even have a machine dedicated to Windows, but I can boot into Windows on my main linux computer. It's just that I got the impression porting a working Firefox extension to Edge was generally easy, so I thought I should give it a try. I thought before I started trying to dig deep into debugging in a platform I'm totally unfamiliar with I would check here if there is some general problem with using x_ite.mjs in the Microsoft Edge browser, thanks.

@gwhitney
Copy link
Contributor Author

gwhitney commented Oct 9, 2023

Hmm, since Edge is based on Chrome, I suppose the following might be the issue:

https://stackoverflow.com/questions/42800035/why-cant-you-create-custom-elements-in-content-scripts

since I am indeed in a content script when this error occurs. I presume that custom elements are necessary for the successful operation of x_ite.mjs? I will try one or more of the solutions on the linked StackOverflow page and report back if I get it working.

@gwhitney
Copy link
Contributor Author

Yes, I can attest that in my case, loading the polyfill published on npm as @webcomponents/custom-elements before attempting to load x_ite.mjs gets it working inside an Edge extension. Probably the same issue will exist in Chrome, I expect. You may want to put a note about this somewhere in the documentation in case anyone else tries to use x_ite in a browser extension; or perhaps this issue and commentary will suffice -- I defer to your judgment. In any case, things seem to be working now.

@create3000
Copy link
Owner

I'm glad you were able to resolve the matter yourself. I'll see if I can find a place for the solution in the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants