Skip to content

Commit

Permalink
IE fix: calling matchMedia with an empty string (#4760)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminclot authored and jsnellbaker committed Jan 22, 2020
1 parent 8ed99d2 commit 4849b19
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/sizeMapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,16 @@ function evaluateSizeConfig(configs) {
) {
let ruleMatch = false;

try {
ruleMatch = getWindowTop().matchMedia(config.mediaQuery).matches;
} catch (e) {
logWarn('Unfriendly iFrame blocks sizeConfig from being correctly evaluated');

ruleMatch = matchMedia(config.mediaQuery).matches;
if (config.mediaQuery === '') {
ruleMatch = true;
} else {
try {
ruleMatch = getWindowTop().matchMedia(config.mediaQuery).matches;
} catch (e) {
logWarn('Unfriendly iFrame blocks sizeConfig from being correctly evaluated');

ruleMatch = matchMedia(config.mediaQuery).matches;
}
}

if (ruleMatch) {
Expand Down

0 comments on commit 4849b19

Please sign in to comment.