I am trying to get a nested IE10+ media query to work in SASS and am not understanding the output. I think that things are getting weird with the use of the media query or
operator ,
. As a result, this query will not apply in all cases because the only thing that is outputted is one side of the or
.
Note that these are originally mixins; i removed the mixins to make things easier to debug
.element {
@media only screen and (min-width: 825px) and (max-width: 999px) {
font-size: 10.4vw;
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
font-size: 9.6vw;
}
}
}
Compiles to this:
@media only screen and (min-width: 825px) and (max-width: 999px) {
.element {
font-size: 10.4vw;
}
}
@media only screen and (min-width: 825px) and (max-width: 999px) and (-ms-high-contrast: active) {
.element {
font-size: 9.6vw;
}
}
The expected outcome is :
@media all and (-ms-high-contrast: none) and (min-width: 825px) and (max-width: 999px), (-ms-high-contrast: active) and (min-width: 825px) and (max-width: 999px) {
.element {
font-size: 9.6vw;
}
}
This appears to be a hyper-specific case that appears is part misbehavior in Sass and part ambiguous expectations.
Sass handles nesting combined with comma delimited media queries without problems... until you start specifying a display type on both the inner and outer query:
Output:
In both cases where both the inner and outer query contains a display type (all, screen), the compiled results do not correctly match what was written. This appears to be a case of Sass trying to write something that resembles a valid media query (since it knows that
screen and all
is not valid).So only specify the display type once.
Compiles to: