Skip to content

Commit

Permalink
Remove references to Less_Environment::$_outputMap
Browse files Browse the repository at this point in the history
Port surrounding code to match the 2.5.3 less.js implementation.

Bug: T352862
Change-Id: I8f4a6256dbd374a7fd063ca8732b898a12d64300
  • Loading branch information
Hannah Okwelum authored and Krinkle committed Feb 19, 2024
1 parent 07dfbb1 commit a37acee
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 41 deletions.
35 changes: 0 additions & 35 deletions lib/Less/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class Less_Environment {

public static $lastRule = false;

public static $_outputMap;
public static $_noSpaceCombinators;

public static $mixin_stack = 0;
Expand All @@ -55,40 +54,6 @@ public function Init() {
' ' => true,
'|' => true
];

if ( Less_Parser::$options['compress'] ) {

self::$_outputMap = [
',' => ',',
': ' => ':',
'' => '',
' ' => ' ',
':' => ' :',
'+' => '+',
'~' => '~',
'>' => '>',
'|' => '|',
'^' => '^',
'^^' => '^^'
];

} else {

self::$_outputMap = [
',' => ', ',
': ' => ': ',
'' => '',
' ' => ' ',
':' => ' :',
'+' => ' + ',
'~' => ' ~ ',
'>' => ' > ',
'|' => '|',
'^' => ' ^ ',
'^^' => ' ^^ '
];

}
}

public function copyEvalEnv( $frames = [] ) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Less/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ private function _minmax( $isMin, $args ) {
foreach ( $order as $a ) {
$args[] = $a->toCSS();
}
return new Less_Tree_Anonymous( ( $isMin ? 'min(' : 'max(' ) . implode( Less_Environment::$_outputMap[','], $args ) . ')' );
return new Less_Tree_Anonymous( ( $isMin ? 'min(' : 'max(' ) . implode( ( Less_Parser::$options['compress'] ? ',' : ', ' ), $args ) . ')' );
}

public function min( ...$args ) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Less/Tree/NameValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function __construct( $name, $value = null, $index = null, $currentFileIn
public function genCSS( $output ) {
$output->add(
$this->name
. Less_Environment::$_outputMap[': ']
. ( Less_Parser::$options['compress'] ? ':' : ': ' )
. $this->value
. $this->important
. ( ( ( Less_Environment::$lastRule && Less_Parser::$options['compress'] ) ) ? "" : ";" ),
Expand Down
4 changes: 2 additions & 2 deletions lib/Less/Tree/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ public function accept( $visitor ) {
}

/**
* @see Less_Tree::genCSS
* @see less-2.5.3.js#Rule.prototype.genCSS
*/
public function genCSS( $output ) {
$output->add( $this->name . Less_Environment::$_outputMap[': '], $this->currentFileInfo, $this->index );
$output->add( $this->name . ( Less_Parser::$options['compress'] ? ':' : ': ' ), $this->currentFileInfo, $this->index );
try {
$this->value->genCSS( $output );

Expand Down
4 changes: 2 additions & 2 deletions lib/Less/Tree/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ public function compile( $env ) {
}

/**
* @see Less_Tree::genCSS
* @see less-2.5.3.js#Value.prototype.genCSS
*/
public function genCSS( $output ) {
$len = count( $this->value );
for ( $i = 0; $i < $len; $i++ ) {
$this->value[$i]->genCSS( $output );
if ( $i + 1 < $len ) {
$output->add( Less_Environment::$_outputMap[','] );
$output->add( Less_Parser::$options['compress'] ? ',' : ', ' );
}
}
}
Expand Down

0 comments on commit a37acee

Please sign in to comment.