diff --git a/lib/utils/getPrefix.js b/lib/utils/getPrefix.js index 0135798e..9d38a9c4 100644 --- a/lib/utils/getPrefix.js +++ b/lib/utils/getPrefix.js @@ -1,12 +1,14 @@ // @flow const prefixes = ['Moz', 'Webkit', 'O', 'ms']; export function getPrefix(prop: string='transform'): string { - // Checking specifically for 'window.document' is for pseudo-browser server-side - // environments that define 'window' as the global context. - // E.g. React-rails (see https://github.com/reactjs/react-rails/pull/84) - if (typeof window === 'undefined' || typeof window.document === 'undefined') return ''; - - const style = window.document.documentElement.style; + // Ensure we're running in an environment where there is actually a global + // `window` obj + if (typeof window === 'undefined') return ''; + + // If we're in a pseudo-browser server-side environment, this access + // path may not exist, so bail out if it doesn't. + const style = window.document?.documentElement?.style; + if (!style) return ''; if (prop in style) return '';