From ec015e2f393070fe79aaa26c4f03a57aeec17acb Mon Sep 17 00:00:00 2001 From: Aaron O'Mullan Date: Tue, 11 Jan 2022 14:41:22 +0100 Subject: [PATCH] fix: isBrowser false positives Feature detect against `document` instead of `window` to avoid false positives in environments like Deno that define a `window` global but no `document` --- src/lib/stylesheet.js | 2 +- src/stylesheet-registry.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/stylesheet.js b/src/lib/stylesheet.js index 38eec882..2781da46 100644 --- a/src/lib/stylesheet.js +++ b/src/lib/stylesheet.js @@ -13,7 +13,7 @@ export default class StyleSheet { constructor({ name = 'stylesheet', optimizeForSpeed = isProd, - isBrowser = typeof window !== 'undefined' + isBrowser = typeof document !== 'undefined' } = {}) { invariant(isString(name), '`name` must be a string') this._name = name diff --git a/src/stylesheet-registry.js b/src/stylesheet-registry.js index d887265d..b3fcdf79 100644 --- a/src/stylesheet-registry.js +++ b/src/stylesheet-registry.js @@ -22,7 +22,7 @@ export class StyleSheetRegistry { constructor({ styleSheet = null, optimizeForSpeed = false, - isBrowser = typeof window !== 'undefined' + isBrowser = typeof document !== 'undefined' } = {}) { this._sheet = styleSheet ||