lightningcss icon indicating copy to clipboard operation
lightningcss copied to clipboard

Incorrect reduction of `clamp` to `min` given a negative bound

Open alcore opened this issue 4 months ago • 0 comments

Given the following...

margin: 100px clamp(-100px, 0px, 50% - 50vw)

... to set a negative horizontal margin when sufficient space is available in the container and viewport, while making sure it doesn't extrude more than 100px outwards (min of -100px) and does not get a positive margin inwards (max of 0px) from the dynamic calc.

LightningCSS (1.27) reduces that to:

margin: 100px min(0px, 50% - 50vw)

It gets correctly retained when the math is expressed by its equivalent instead:

margin: 100px max(-100px, min(0px, 50% - 50vw))

alcore avatar Oct 16 '24 12:10 alcore