less / less.js

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

Line comments aren't stripped from @supports selector(...) #3527

Open thorn0 opened 4 years ago

thorn0 commented 4 years ago

Is this a bug or is this an expected behavior?

Demo (Less 3.11.3): https://jsbin.com/hewizek/6/edit?html,js,console

Input:

@supports selector(
  :focus-visible // *"a"
) {
  a { 
    color: red;
  }
}

Output:

@supports selector(
    :focus-visible // *"a") {
  a {
    color: red;
  }
}

Expected:

@supports selector(:focus-visible) {
  a {
    color: red;
  }
}
matthew-dean commented 4 years ago

It's expected behavior, although of course not ideal. The @supports tag and some other at-rules that are not explicitly parsed basically allow anything in the at-rule prelude, and just look for matching blocks (like parentheses).

This is being re-worked in a smarter parser for Less v5, but there is no timeline currently for that release.