From c9bea3019b0d4fa52adfa28fc81b8713f56360f5 Mon Sep 17 00:00:00 2001 From: yiminghe Date: Mon, 26 Oct 2015 20:03:37 +0800 Subject: [PATCH] guard window --- index.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index ae49da7b47..8ed3d93c3b 100644 --- a/index.js +++ b/index.js @@ -2,15 +2,18 @@ require('./style/index.less'); // matchMedia polyfill for // https://github.com/WickyNilliams/enquire.js/issues/82 -window.matchMedia = window.matchMedia || function () { - return { - matches: false, - addListener: function () { - }, - removeListener: function () { - } +if (typeof window !== 'undefined') { + const matchMediaPolyfill = function matchMediaPolyfill() { + return { + matches: false, + addListener: function () { + }, + removeListener: function () { + } + }; }; -}; + window.matchMedia = window.matchMedia || matchMediaPolyfill; +} const antd = { Affix: require('./components/affix'), -- GitLab