less / less.js

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

Container style queries unexpected space #4235

Open woody-li opened 1 year ago

woody-li commented 1 year ago

To reproduce:

https://lesscss.org/less-preview/#eyJjb2RlIjoiQGNvbnRhaW5lciBzdHlsZSgtLXRoZW1lOiBkYXJrKXtcbiAgLm1haW57XG4gICAgY29sb3I6IzAwMDtcbiAgfVxufVxuXG4iLCJhY3RpdmVWZXJzaW9uIjoiNC4yLjAiLCJtYXRoIjoicGFyZW5zLWRpdmlzaW9uIiwic3RyaWN0VW5pdHMiOmZhbHNlfQ==

@container style(--theme: dark){
  .main{
    color: #000;
  }
}

Current behavior: There's a space between "style" and the bracket.

@container style (--theme: dark)

Expected behavior: No space between "style" and the bracket.

@container style(--theme: dark)

Environment information:

haseeb196 commented 1 year ago

Maybe this is not a error the less code is correct but some text editors and Markdown renderers might automatically add a space after type and it does not affect the functionality of the code.

woody-li commented 1 year ago

@haseeb196 But it doesn't take effect in Chrome when contains a space. Seems the "style" is recognized as a function.

matthew-dean commented 1 year ago

Sorry what? AFAIK, @container [function] is not valid, unless you can point to where it is.

woody-li commented 1 year ago

@matthew-dean I don't ensure it's a function. But according to the specification, the style syntax: style( <style-query> ) looks like a function.

Only Chrome has implemented the container style query so far, and it cannot take effect when a space exists between style and bracket.

matthew-dean commented 1 year ago

@woody-li Ah, okay, your issue was written confusingly, because type( would be invalid. (I'm not sure why you didn't write style( in your example?) I see the style( reference now, my bad.

woody-li commented 1 year ago

Sorry for my mistake, it should be style. Thanks

ghazanfarofficial01 commented 1 year ago

How can I contribute to this issue?

BhushanNalawade commented 12 months ago

How to contribute to this issue?

rejhgadellaa commented 2 months ago

Any news on this? Safari 18 now supports container style queries as well, so would be nice to have this fix land in prod. Thnx!

rejhgadellaa commented 2 months ago

FWIW, you can work around this issue by escaping the style() query:

@container ( ~"style(--theme: light)" )

For @ variables:

@container ( ~"style(--theme: @{theme})" )

(you need the extra ( ... ) around the style() query or less will complain about them missing)

woody-li commented 1 week ago

@matthew-dean The release PR has merged, could you help to release new version to npm.