-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
document is not defined #3196
Comments
This is a bizarre environment. Why does it work like that? |
I can't really tell you 😄 |
To assess this issue I need to know, at the very least, where this |
I'm not an angular expert, but I think it works like this because angular is using html element class for rendering, so it needs to have this primitive available on SSR. And it doesn't need the whole |
I think it's kinda not correct to check |
Could u check if the new version works in this context? |
Yes, seems like it's fixed. Thank you ❤️ |
Hey, sorry my previous comment was wrong. I didn't test it properly and the problem is still there. It still only checks for HtmlElement and not document. |
Current behavior:
In some environments, checking for
typeof HTMLElement !== undefined
might not be enough, when accessingdocument
.We use emotion in @tolgee/ngx in a dev tools dialog (which is in react). However when using this package in angular 17 SSR, it fails, because it's trying to access
document
.emotion/packages/react/src/context.js
Line 15 in fc74bee
To reproduce:
https://stackblitz.com/edit/fuck-yeah-angular-ssr-1e3ut7
Seems like in angular SSR environment
document
is undefined, butHTMLElement
is not, which is causing the issue.Expected behavior:
I think this check should be more robust e.g
typeof document !== 'undefined' && typeof HtmlElement !== 'undefined'
.We are not actually rendering anything using emotion, it's just a part of the package, but since
createCache
is called immediately when we import the file.If I replace this check with
typeof HTMLElement !== undefined && typeof document !== undefined
, it is resolved.Environment information:
@emotion/react
version: 11.11.4The text was updated successfully, but these errors were encountered: