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

preact crashes while using with mui #422

Closed
wight554 opened this issue Mar 19, 2022 · 2 comments
Closed

preact crashes while using with mui #422

wight554 opened this issue Mar 19, 2022 · 2 comments
Labels
bug Something isn't working high priority

Comments

@wight554
Copy link

After adding mui to preact project, my test started crashing here:
https://github.com/capricorn86/happy-dom/blob/master/packages/happy-dom/src/nodes/document/Document.ts#L615
The error:

 FAIL  test/src/components/App/App.test.tsx > App > should render title
TypeError: Cannot read properties of undefined (reading 'toUpperCase')
 ❯ CustomElementRegistry.get node_modules/happy-dom/lib/custom-element/CustomElementRegistry.js:54:36
 ❯ HTMLDocument.Document.createElementNS node_modules/happy-dom/lib/nodes/document/Document.js:664:66
 ❯ HTMLDocument.Document.createElement node_modules/happy-dom/lib/nodes/document/Document.js:644:21
 ❯ j node_modules/preact/dist/preact.js:1:6618
 ❯ I node_modules/preact/dist/preact.js:1:6013
 ❯ m node_modules/preact/dist/preact.js:1:2096
 ❯ j node_modules/preact/dist/preact.js:1:7049
 ❯ I node_modules/preact/dist/preact.js:1:6013
 ❯ m node_modules/preact/dist/preact.js:1:2096
 ❯ I node_modules/preact/dist/preact.js:1:5831

tried logging args and got this:

stdout | unknown test
http://www.w3.org/1999/xhtml div undefined
http://www.w3.org/1999/xhtml style undefined
http://www.w3.org/1999/xhtml div undefined
http://www.w3.org/1999/xhtml undefined undefined

I managed to fix it by doing (qualifiedName || '').toUpperCase(), but there might be a better fix

wight554 added a commit to wight554/blog-template that referenced this issue Mar 23, 2022
wight554 added a commit to wight554/blog-template that referenced this issue Mar 23, 2022
@capricorn86 capricorn86 added bug Something isn't working high priority labels Mar 27, 2022
@capricorn86
Copy link
Owner

Thanks for reporting @wight554! 🙂

It is a weird error. It seems like MUI sends in something else than a string to document.createElement() (e.g. document.createElement(undefined)).

It is most likely a bug in MUI, but apparently it is supported to send in other types in the browser as it is parsed to a string. I have added support for converting the value to a string now.

You can read more about the release here:
https://github.com/capricorn86/happy-dom/releases/tag/v2.53.1

@wight554
Copy link
Author

That might be how CssBaseline work, thanks for a fix anyway

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority
Projects
None yet
Development

No branches or pull requests

2 participants