-
-
Notifications
You must be signed in to change notification settings - Fork 79k
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
Be SSR friendly when accessing DOM objects #34989
Conversation
d73d835
to
7ea4c57
Compare
Fixed a few omissions in SSR when testing stuff. Can't make a pull request to pull request. |
@xvaara you should be able to open a PR against this branch. If you still can't I'd need to cherry pick it, but makes me wonder how those weren't caught. |
#35165 has my changes. |
4a78b80
to
dd315ad
Compare
d49a667
to
426235a
Compare
426235a
to
22cf0ed
Compare
Added the last missing in #35339 |
I'm using Vite and vite-ssr. Some of these problems only came up when I was actually rendering the page. |
Just tested with straight running the bundle with node it fails on this branch, but returns without fail on my branch:
and the CommonJS bundle fails also:
|
Any updates on this? We are using Bootstrap with Next.js and running into these issues. |
232a724
to
ac8ca6d
Compare
We discussed it with @XhmikosR and concluded that it is not perfect (as it seems linter misses some cases), but it is a nice start to support ssr. So I re-re-based it, wishing for last time @xvaara I am aware of your PR and it is much appreciated. As the linter doesn't inspect any other errors, we will go with it, and in order to proceed on future PRs we will need some tests, to support the proposed fixes. So if you are aware of any simple way, you are welcome to help on this |
2d4d48b
to
6d7f20f
Compare
|
6d7f20f
to
a713b37
Compare
a713b37
to
331a935
Compare
Thank you guys for the efforts around this issue. I'm using BS5 with Angular's pre-rendering and since it bundles the entire app with Webpack and I can't simply load a module when I need it. I've posted about this here: https://stackoverflow.com/questions/76005487/angular-prerendering-using-js-conditionally-causes-document-is-not-defined Now, one of the problems I see is that Bootstrap shouldn't assume it is always running on a browser and start calling stuff like |
Just an update, I tried the code in this PR and it seems to fix the
I traced this back to here bootstrap/js/src/dom/event-handler.js Line 201 in 331a935
After wrapping it like this:
I got bootstrap/js/src/util/index.js Line 235 in 331a935
I proceeded to change the function to:
And finally I got a working build that can be used with Angular's pre-rendering! Can you guys @Johann-S or @XhmikosR apply this changes, or some similar code that you find more reasonable into this PR? Thank you. |
I did manage to commit the proposed changes in another PR at #38460. Thank you. |
Closing due to being outdated. |
Rebased version of: #33131
TODO:
document
andwindow