Skip to content

Add context.ts to hold hasWindow flag and browser's window and document objects.#1153

Merged
dpvc merged 4 commits intodevelopfrom
context
Nov 15, 2024
Merged

Add context.ts to hold hasWindow flag and browser's window and document objects.#1153
dpvc merged 4 commits intodevelopfrom
context

Conversation

@dpvc
Copy link
Copy Markdown
Member

@dpvc dpvc commented Nov 6, 2024

This PR creates a context object that holds the browser window and document values, if they exist, simplifying tests for when we are in a Node application versus the browser. It then converts uses of typeof window === 'undefined' and typeof document === 'undefined' to use this new object. This reduces redundant code, and puts the browser detection into one location.

@dpvc dpvc requested a review from zorkow November 6, 2024 20:03
@dpvc dpvc added this to the v4.0 milestone Nov 6, 2024
Copy link
Copy Markdown
Member

@zorkow zorkow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One typo. Otherwise fine.
Makes things look a lot cleaner!

Comment thread ts/ui/menu/MenuUtil.ts Outdated
@dpvc dpvc merged commit dfe1389 into develop Nov 15, 2024
@dpvc dpvc deleted the context branch November 15, 2024 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants