less.js icon indicating copy to clipboard operation
less.js copied to clipboard

LESS if() function collides with CSS if() function

Open paponius opened this issue 1 month ago • 7 comments

To reproduce: A property with an if() function using native CSS syntax in LESS space.

	color: if(style(color: none): blue; else: red);

Current behavior:

Error: Could not parse call arguments or missing ')'

Expected behavior:

A possibility to use the native CSS if() function directly, without a hack: color: ~"if(style(color: none): blue; else: red);"

Environment information:

Used within Stylus browser extension.

  • less version: 4.4.2 (based on https://github.com/openstyles/stylus/blob/master/package.json)
  • nodejs version: unknown
  • operating system: any

Proposed solution:
Determine whether LESS parser should process if() function or pass it on, by its syntax.
LESS syntax: three parameters https://lesscss.org/functions/#logical-functions-if
native CSS syntax: one comma separated "parameter" https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/if#syntax

paponius avatar Nov 11 '25 17:11 paponius