Skip to content

Commit 217631b

Browse files
committed
Handle pseudo-browser environments when rendering server-side
1 parent d20f540 commit 217631b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/utils/getPrefix.es6

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
export default (function() {
2-
if (typeof window === 'undefined') return '';
2+
// Checking specifically for 'window.document' is for pseudo-browser server-side
3+
// environments that define 'window' as the global context.
4+
// E.g. React-rails (see https://github.com/reactjs/react-rails/pull/84)
5+
if (typeof window === 'undefined' || typeof window.document === 'undefined') return '';
6+
37
// Thanks David Walsh
48
let styles = window.getComputedStyle(document.documentElement, ''),
59
pre = (Array.prototype.slice

0 commit comments

Comments
 (0)