-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fix(browser/v7): Don't assume window.document is available #11598
Conversation
size-limit report 📦
|
I'm wondering if it's feasible to drop the DOM-lib in this project's tsconfig, to prevent accidental breakage for WebWorkers? And a small review nudge: I personally really like optional chaining to turn if (WINDOW.document) WINDOW.document.addEventListener(...) into WINDOW.document?.addEventListener(...) (Might not apply here due to code style or something. Putting it out here just in case) |
if (WINDOW.document) { | ||
WINDOW.document.addEventListener('visibilitychange', () => { |
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.
l/feel free to ignore: This should be safe here, right?
if (WINDOW.document) { | |
WINDOW.document.addEventListener('visibilitychange', () => { | |
if (WINDOW.document) { | |
addEventListener('visibilitychange', () => { |
@@ -292,7 +292,7 @@ export const browserTracingIntegration = ((_options: Partial<BrowserTracingOptio | |||
|
|||
if (isPageloadTransaction && WINDOW.document) { | |||
WINDOW.document.addEventListener('readystatechange', () => { | |||
if (['interactive', 'complete'].includes(WINDOW.document.readyState)) { | |||
if (['interactive', 'complete'].includes(WINDOW.document!.readyState)) { |
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.
l: does TS not infer the definedness of WINDOW.document
from above? maybe not because of the callback?
Optional chaining transpiles into larger bundle size than we want if you don't target es2020 (which we don't atm). |
Relates to #5289 (comment)
We technically support webworkers so we cannot assume that document API is available.