As more and more browsers support range syntax, the syntax of @media becomes complex and the current regular expression substitution pattern will become difficult to maintain.
For example, the following rules are valid in browsers.
@media (900px = width) {}
@media (900px < width) {}
@media (900px <= width) {}
@media (900px <= width <= 1200px) {}
@media ( width > calc(5px + 1rem) ) {}
@media ( width < calc(Infinity * 1px) ) {}
@media ( width > max(30px, 30em) ) {}
@media not (900px > width) {}
@media (width >= 900px) and (not (width = 910px)) {}
@media (width >= 500px) and ((499px > width) or (not (width = 500px))) {}
There are also new @container rules:
@container layout-name (width >= 500px) {}
So, consider a complete refactoring in the new version, adding a dedicated at rule parser to parse them. Perhaps a good place to start is to investigate css-tree in conjunction with PostCSS.
The postcss-media-minmax plugin is very popular, with over 6 million downloads per week. The refactoring will maintain better compatibility with browsers, which will be significant.
Feel free to discuss, PR or sponsor!
Related packages
Spec issue
As more and more browsers support range syntax, the syntax of
@mediabecomes complex and the current regular expression substitution pattern will become difficult to maintain.For example, the following rules are valid in browsers.
There are also new
@containerrules:So, consider a complete refactoring in the new version, adding a dedicated at rule parser to parse them. Perhaps a good place to start is to investigate css-tree in conjunction with PostCSS.
The
postcss-media-minmaxplugin is very popular, with over 6 million downloads per week. The refactoring will maintain better compatibility with browsers, which will be significant.Feel free to discuss, PR or sponsor!
Related packages
Spec issue
<mf-range>"swapping value and name" syntax really useful? w3c/csswg-drafts#2791