Skip to content

Commit

Permalink
IE fix: calling matchMedia with an empty string (prebid#4691)
Browse files Browse the repository at this point in the history
* IE fix for matchMedia

matchMedia throws an error if it gets an empty string as parameter on IE

* Removed trailing space
  • Loading branch information
benjaminclot authored and audiencerun committed Jan 20, 2020
1 parent d0edd12 commit dd0b3f8
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
@@ -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) {

0 comments on commit dd0b3f8

Please sign in to comment.