-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IE fix: calling matchMedia with an empty string #4691
IE fix: calling matchMedia with an empty string #4691
Conversation
Fork update
matchMedia throws an error if it gets an empty string as parameter on IE
As a side note, this should also be merged into the |
Hi @benjaminclot, I see your point, when we have a pbjs.setConfig([{
sizeConfig: {
mediaQuery: '',
sizesSupported: [
[728, 90],
[300, 250]
],
labels: ['desktop', 'tablet']
}
}]); Currently, we don't have any checks in place to indicate to the user that mediaQuery string is declared an empty string. Ideally, this shouldn't be allowed, i.e, providing an empty string for With your approach, where you are setting For example, consider this ad unit setup. {
code: "ad-slot-1",
mediaTypes: {
banner: {
sizes: [
[970, 90],
[728, 90],
[300, 250],
[300, 100]
]
}
},
bids: [{
bidder: "pulsepoint",
labelAny: ["desktop", "tablet"],
params: {
"cf": "728X90",
"cp": 123456,
"ct": 123456
}
},
{
bidder: "pulsepoint",
labelAny: ["desktop", "phone"],
params: {
"cf": "300x250",
"cp": 123456,
"ct": 123456
}
}]
} Let's say the user is accessing the webpage from a mobile phone and viewport width is A simple fix, that I can think of now is: if (
typeof config === 'object' &&
typeof config.mediaQuery === 'string' &&
config.mediaQuery.length > 0
) {
...
}
} We can just put this extra check in place Let me know what you think. |
Hi @Fawke, The goal of my proposition was to have IE behave like Chrome and not introduce a potential breaking change. In your example, you deduce that |
We'll review this internally with other prebid.js engineers and let them take a call if we should block this behaviour completely or allow it for IE (and other browsers). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this matches the behavior of chrome, then I think it's an appropriate fix for IE. LGTM
In this case, since the undefined behavior is behaving differently in different browsers, we should not make the breaking change unless it's in a major release. So for now this fix is good, but @Fawke we should make the breaking change in a future 4.x release. Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Merging this master. This issue will be tracked and adding mediaQuery
as an empty string would be disallowed from next major version of Prebid.js
* IE fix for matchMedia matchMedia throws an error if it gets an empty string as parameter on IE * Removed trailing space
* IE fix for matchMedia matchMedia throws an error if it gets an empty string as parameter on IE * Removed trailing space
Type of change
Description of change
In IE, calling
matchMedia
with an empty string throws an error.