Skip to content

Commit

Permalink
Improve code for better compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
ztplz committed Sep 16, 2019
1 parent 9ea143b commit 440c71d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion components/_util/responsiveObserve.ts
Expand Up @@ -2,6 +2,7 @@
// https://github.com/WickyNilliams/enquire.js/issues/82
let enquire: any;

// TODO: Will be removed in antd 4.0 because we will no longer support ie9
if (typeof window !== 'undefined') {
const matchMediaPolyfill = (mediaQuery: string) => {
return {
Expand All @@ -11,7 +12,8 @@ if (typeof window !== 'undefined') {
removeListener() {},
};
};
window.matchMedia = window.matchMedia || matchMediaPolyfill;
// ref: https://github.com/ant-design/ant-design/issues/18774
if (!window.matchMedia) window.matchMedia = matchMediaPolyfill as any;
// eslint-disable-next-line global-require
enquire = require('enquire.js');
}
Expand Down
4 changes: 3 additions & 1 deletion components/carousel/index.tsx
Expand Up @@ -6,6 +6,7 @@ import warning from '../_util/warning';

// matchMedia polyfill for
// https://github.com/WickyNilliams/enquire.js/issues/82
// TODO: Will be removed in antd 4.0 because we will no longer support ie9
if (typeof window !== 'undefined') {
const matchMediaPolyfill = (mediaQuery: string) => {
return {
Expand All @@ -15,7 +16,8 @@ if (typeof window !== 'undefined') {
removeListener() {},
};
};
window.matchMedia = window.matchMedia || matchMediaPolyfill;
// ref: https://github.com/ant-design/ant-design/issues/18774
if (!window.matchMedia) window.matchMedia = matchMediaPolyfill as any;
}
// Use require over import (will be lifted up)
// make sure matchMedia polyfill run before require('react-slick')
Expand Down
4 changes: 3 additions & 1 deletion components/layout/Sider.tsx
Expand Up @@ -11,6 +11,7 @@ import isNumeric from '../_util/isNumeric';

// matchMedia polyfill for
// https://github.com/WickyNilliams/enquire.js/issues/82
// TODO: Will be removed in antd 4.0 because we will no longer support ie9
if (typeof window !== 'undefined') {
const matchMediaPolyfill = (mediaQuery: string) => {
return {
Expand All @@ -20,7 +21,8 @@ if (typeof window !== 'undefined') {
removeListener() {},
};
};
window.matchMedia = window.matchMedia || matchMediaPolyfill;
// ref: https://github.com/ant-design/ant-design/issues/18774
if (!window.matchMedia) window.matchMedia = matchMediaPolyfill as any;
}

const dimensionMaxMap = {
Expand Down

0 comments on commit 440c71d

Please sign in to comment.