While reviewing the Fx Quantum 57 release notes, particularly the Quantum CSS notes, a comparison between Gecko and Stylo reveals various discrepancies along with some potential workarounds.
One notable difference highlighted is:
A suggested approach involves using @supports
with a calc(0s)
expression in combination with @-moz-document
to test for Stylo support — as Gecko does not handle <time> values within calc()
expressions unlike Stylo:
@-moz-document url-prefix() {
@supports (animation: calc(0s)) {
/* Stylo */
}
}
For illustration purposes, consider this proof-of-concept:
body::before {
content: 'Not Fx';
}
@-moz-document url-prefix() {
body::before {
content: 'Fx legacy';
}
@supports (animation: calc(0s)) {
body::before {
content: 'Fx Quantum';
}
}
}
It's worth noting that Fx Quantum versions 59 and 60 initially restricted the usage of @-moz-document
on public documents, but version 61 reinstated support for the @-moz-document url-prefix()
technique, enabling it to function as intended. However, since version 60 is an ESR release, adjustments are required if targeting that specific version by switching the @-moz-document
at-rule to a media query:
@media (-moz-device-pixel-ratio) {
@supports (animation: calc(0s)) {
/* Stylo */
}
}
Dealing with older versions of Firefox can be challenging — focusing solely on versions supporting @supports
, starting from Fx 22 and onwards, can be achieved using
@supports not (animation: calc(0s))
:
@-moz-document url-prefix() {
@supports not (animation: calc(0s)) {
/* Gecko */
}
}
However, for even earlier versions' compatibility, leveraging the cascading nature of CSS is recommended, as shown in the previously mentioned proof-of-concept.