less / less.js

Less. The dynamic stylesheet language.
http://lesscss.org
Apache License 2.0
16.99k stars 3.41k forks source link

Empty calculation passed to css in 4.2.0 #4256

Open MagpieRook opened 6 months ago

MagpieRook commented 6 months ago

To reproduce:

Use any min or max function alongside a CSS variable. The breaking change in my deployed environment is:

:root {
  --body-max-width: 1200px;
}

#main-content {
  max-width: min(var(--body-max-width), calc(100vw - 20px));
}

However, another call to min without CSS variables is passed appropriately:

.carousel {
  --caption-width: min(600px, 100%);
}

Current behavior:

In 4.1.3, both the max-width statement and the --caption-width variable are passed as-is to the CSS file. In 4.2.0, the CSS file produced instead has max-width: min();.

Expected behavior:

A non-empty max-width: min();.

Environment information:

This occurs with max, as well, but not calc, which makes me think it's related to #3719.

iChenLei commented 6 months ago

PR welcome

matthew-dean commented 5 months ago

Would this address it?

SoonIter commented 3 months ago

It's a similar problem https://lesscss.org/less-preview/#eyJjb2RlIjoiLmJveCB7XG4gIHdpZHRoOiBtaW4ofid2YXIoLS13aWR0aCksIDgwMnB4Jyk7XG59IiwiYWN0aXZlVmVyc2lvbiI6IjQuMi4wIiwibWF0aCI6InBhcmVucy1kaXZpc2lvbiIsInN0cmljdFVuaXRzIjpmYWxzZX0=

image image
matthew-dean commented 3 months ago

@SoonIter Same question as here: https://github.com/less/less.js/issues/4256#issuecomment-1883335763