Skip to content

Commit 22b0615

Browse files
committed
fix(getPrefix): ensure documentElement.style actually exists
Fixes #574, #575
1 parent 72a7660 commit 22b0615

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/utils/getPrefix.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
// @flow
22
const prefixes = ['Moz', 'Webkit', 'O', 'ms'];
33
export function getPrefix(prop: string='transform'): string {
4-
// Checking specifically for 'window.document' is for pseudo-browser server-side
5-
// environments that define 'window' as the global context.
6-
// E.g. React-rails (see https://github.com/reactjs/react-rails/pull/84)
7-
if (typeof window === 'undefined' || typeof window.document === 'undefined') return '';
8-
9-
const style = window.document.documentElement.style;
4+
// Ensure we're running in an environment where there is actually a global
5+
// `window` obj
6+
if (typeof window === 'undefined') return '';
7+
8+
// If we're in a pseudo-browser server-side environment, this access
9+
// path may not exist, so bail out if it doesn't.
10+
const style = window.document?.documentElement?.style;
11+
if (!style) return '';
1012

1113
if (prop in style) return '';
1214

0 commit comments

Comments
 (0)