fix: preserve parentheses around "or" in @media with type by veeceey · Pull Request #4406 · evanw/esbuild (original) (raw)

@veeceey

The CSS minifier was dropping grouping parentheses around "or" expressions when they appeared after a media type + "and", producing invalid CSS. For example:

@media screen and ((min-width: 10px) or (min-height: 10px))

was being minified to:

@media screen and (min-width:10px)or (min-height:10px)

This is invalid because CSS does not allow mixing "and" and "or" at the same nesting level. The spec requires the "or" group to be wrapped in parentheses as a production.

The fix passes mqNeedsParens when printing the condition from an MQType node if the condition is an "or" binary, ensuring the outer parentheses are preserved.

Fixes evanw#4395