Skip to content

Commit bed2c0c

Browse files
anny21Krinkle
authored andcommitted
Support functions calls in CSS variable value after first comma
See https://github.com/less/less.js/pull/4237/files Bug: T386079 Change-Id: Ifdbd79ad445bff1bedbc21c76be53132e128e57f
1 parent 606e045 commit bed2c0c

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

lib/Less/Parser.php

+5
Original file line numberDiff line numberDiff line change
@@ -2538,6 +2538,11 @@ private function parsePermissiveValue( $untilTokens = null ) {
25382538
if ( $e ) {
25392539
$value[] = $e;
25402540
}
2541+
// NOTE: Comma handling backported from Less.js 4.2.1 (T386077)
2542+
if ( $this->peekChar( ',' ) ) {
2543+
$value[] = new Less_Tree_Anonymous( ',' );
2544+
$this->matchChar( ',' );
2545+
}
25412546
} while ( $e );
25422547
$done = $testCurrentChar( $this->input[$this->pos] );
25432548
if ( $value ) {

lib/Less/Tree/Expression.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ public function genCSS( $output ) {
6969
for ( $i = 0; $i < $val_len; $i++ ) {
7070
$this->value[$i]->genCSS( $output );
7171
if ( !$this->noSpacing && ( $i + 1 < $val_len ) ) {
72-
$output->add( ' ' );
72+
// NOTE: Comma handling backported from Less.js 4.2.1 (T386077)
73+
if ( !( $this->value[$i + 1] instanceof Less_Tree_Anonymous )
74+
|| ( $this->value[$i + 1] instanceof Less_Tree_Anonymous && $this->value[$i + 1]->value !== ',' )
75+
) {
76+
$output->add( ' ' );
77+
}
7378
}
7479
}
7580
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.test {
2+
--background: linear-gradient(270deg, rgba(0, 0, 0, 0) 36.5%, #000 98%), linear-gradient(180deg, rgba(0, 0, 0, 0.9) 0%, rgba(0, 0, 0, 0) 35%);
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@color-black: #000;
2+
3+
.test {
4+
--background:
5+
linear-gradient(270deg, fade(@color-black, 0%) 36.5%, @color-black 98%),
6+
linear-gradient(180deg, fade(@color-black, 90%) 0%, fade(@color-black, 0%) 35%);
7+
}

0 commit comments

Comments
 (0)