-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Check global.window on DOM availability check #5547
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
c431a37
to
de2bd1a
Compare
de2bd1a
to
9cf6283
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I remember we had issues with window
in the past #1400 ; even if this works fine I believe this PR might not be complete (iframe support and other occurences, we introduced this window utility for this
lexical/packages/lexical/src/LexicalUtils.ts
Lines 1296 to 1302 in a5b20c0
export function getWindow(editor: LexicalEditor): Window { | |
const windowObj = editor._window; | |
if (windowObj === null) { | |
invariant(false, 'window object not found'); | |
} | |
return windowObj; | |
} |
There are some use cases
@lexical/headless
and$generateHtmlFromNodes
in the server side andnextjs
is probably the most common framework to implement this.I found some issue and discussions related to this:
generateHtmlFromNodes
correctly for SSR #3616I've met same situation as well, which is that
@lexical/headless
is not compatible withnextjs
servserside even withjsdom
(orhappy-dom
) since #3102 (v.0.6.0)I don't know why but anyway in
nextjs
,typeof window
is stillundefined
after assigningglobal.window
.So it fails type assertion fixed in #3102.
Can reproduce here:
-> you can see it works with
lexical@0.5.0
andnextjs
but in the console you also can seetypeof window
is stillundefined
whileglobal.window
is changed as we assign.So could we check
typeof global.window
withtypeof window
?