-
-
Notifications
You must be signed in to change notification settings - Fork 983
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
support server side rendering #461
Conversation
@@ -1101,4 +1103,4 @@ | |||
|
|||
|
|||
|
|||
})(window || {}); | |||
})(typeof window !== 'undefined' && window); |
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.
Couldn't this line now just be this?
})(window)
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.
no, it will throw an exception because the global variable window
is not defined. I got inspiration from this. But I don't think we need that many checks here
I've merged this in by hand, as you added it to the code in Thanks. |
sorry but the merge you did is wrong. it really needs to be
accessing the window object if it's undefined will throw and exception, whereas |
OK, so simplifying to just not pass in
Is that ok? |
it's a weird way to do that but as long as you don't try to access the Out of curiosity, what was wrong with the implementation in my PR? |
You added it to the wrong files. You put it into the `js` folder instead of
the `src` folder. So I had to copy it by hand and as I was doing that I
tried to simplify it.
The `(window || {})` in the IIFE was a previous PR from someone to work
around an issue like this. If that no longer works, there doesn’t seem to
be much reason to pass window in from there anymore.
|
I would just port the change as it is, even though it was done to the wrong files its semantics still apply. |
When using in server side rendering scenarios (i.e using React) this package once required will throw an exception because the
window
object is not defined.This fix prevents both host and guest scripts from doing anything if the
window
object is not defined, preserving the same behavior when used client side.