Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit 96d590c

Browse files
committed
fix(userLocales): guard against window on node enviroments
CodeSandBox was defining window and global.
1 parent 44990cb commit 96d590c

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ This is a monorepo containing the following packages:
2424

2525
| Package | Package<br>Size | Node | Chrome | Firefox | Safari | Edge |
2626
| -----------------: | :-------------: | :--: | :----: | :-----: | :----: | :--: |
27-
| `preferred-locale` | ≤ 642 bytes | 10+ | 69+ | 68+ | 12+ | 18+ |
27+
| `preferred-locale` | ~580 bytes | 10+ | 69+ | 68+ | 12+ | 18+ |
2828

2929
## Why?
3030

packages/preferred-locale/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
| Package | Package<br>Size | Node | Chrome | Firefox | Safari | Edge |
2626
| -----------------: | :-------------: | :--: | :----: | :-----: | :----: | :--: |
27-
| `preferred-locale` | ≤ 642 bytes | 10+ | 69+ | 68+ | 12+ | 18+ |
27+
| `preferred-locale` | ~580 bytes | 10+ | 69+ | 68+ | 12+ | 18+ |
2828

2929
## Why?
3030

packages/preferred-locale/src/utils/userLocales/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* @private
66
*/
77
export const userLocales = fallback => {
8-
if (global?.navigator?.languages) return navigator.languages.concat([ fallback ])
8+
if (typeof window === 'object' && window?.navigator?.languages) return window.navigator.languages.concat([ fallback ])
99
if (Intl && 'DateTimeFormat' in Intl) return [ Intl.DateTimeFormat().resolvedOptions().locale, fallback ]
1010
return [ fallback ]
1111
}

0 commit comments

Comments
 (0)