From 849304bfcdbf23fc582ebdca0f5f3a71edb532f7 Mon Sep 17 00:00:00 2001 From: Robert Sun Date: Tue, 12 Nov 2024 12:41:24 +1100 Subject: [PATCH 1/2] chore: add more defensive checks on global usage --- packages/number-flow/src/styles.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/number-flow/src/styles.ts b/packages/number-flow/src/styles.ts index c10f195e..f05281f5 100644 --- a/packages/number-flow/src/styles.ts +++ b/packages/number-flow/src/styles.ts @@ -2,12 +2,16 @@ import { BROWSER } from './util/env' import { css } from './util/css' export const supportsLinear = - BROWSER && typeof CSS !== 'undefined' && CSS.supports('animation-timing-function', 'linear(1,2)') + BROWSER && + typeof CSS !== 'undefined' && + CSS.supports && + CSS.supports('animation-timing-function', 'linear(1,2)') export const supportsMod = - BROWSER && typeof CSS !== 'undefined' && CSS.supports('line-height', 'mod(1,1)') + BROWSER && typeof CSS !== 'undefined' && CSS.supports && CSS.supports('line-height', 'mod(1,1)') -export const prefersReducedMotion = BROWSER ? matchMedia('(prefers-reduced-motion: reduce)') : null +export const prefersReducedMotion = + BROWSER && matchMedia ? matchMedia('(prefers-reduced-motion: reduce)') : null // Register animated vars: export const opacityDeltaVar = '--_number-flow-d-opacity' From 13a66fba336c53687664ad9b859ec705891fce2a Mon Sep 17 00:00:00 2001 From: Maxwell Barvian Date: Mon, 11 Nov 2024 21:30:13 -0800 Subject: [PATCH 2/2] Create tasty-cycles-chew.md --- .changeset/tasty-cycles-chew.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .changeset/tasty-cycles-chew.md diff --git a/.changeset/tasty-cycles-chew.md b/.changeset/tasty-cycles-chew.md new file mode 100644 index 00000000..4f2560dc --- /dev/null +++ b/.changeset/tasty-cycles-chew.md @@ -0,0 +1,8 @@ +--- +'number-flow': patch +'@number-flow/react': patch +'@number-flow/svelte': patch +'@number-flow/vue': patch +--- + +More defensive checks on browser globals (see #58)