| 1 |
<?php |
| 2 |
/** |
| 3 |
* A simple CSS name-value pair, e.g. `width: 100px;` |
| 4 |
* |
| 5 |
* In bootstrap, there are about 600-1000 simple name-value pairs (depending on |
| 6 |
* how forgiving the match is) -vs- 6,020 dynamic rules (Less_Tree_Declaration). |
| 7 |
* |
| 8 |
* Using the name-value object can speed up bootstrap compilation slightly, but |
| 9 |
* it breaks color keyword interpretation: `color: red` -> `color: #FF0000`. |
| 10 |
* |
| 11 |
* @private |
| 12 |
*/ |
| 13 |
class Less_Tree_NameValue extends Less_Tree implements Less_Tree_HasValueProperty { |
| 14 |
|
| 15 |
/** @var string */ |
| 16 |
public $name; |
| 17 |
/** @var string */ |
| 18 |
public $value; |
| 19 |
/** @var int|null */ |
| 20 |
public $index; |
| 21 |
/** @var array|null */ |
| 22 |
public $currentFileInfo; |
| 23 |
/** @var string */ |
| 24 |
public $important = ''; |
| 25 |
|
| 26 |
public function __construct( $name, $value = null, $index = null, $currentFileInfo = null ) { |
| 27 |
$this->name = $name; |
| 28 |
$this->value = $value; |
| 29 |
$this->index = $index; |
| 30 |
$this->currentFileInfo = $currentFileInfo; |
| 31 |
} |
| 32 |
|
| 33 |
public function genCSS( $output ) { |
| 34 |
$output->add( |
| 35 |
$this->name |
| 36 |
. ( Less_Parser::$options['compress'] ? ':' : ': ' ) |
| 37 |
. $this->value |
| 38 |
. $this->important |
| 39 |
. ( ( ( Less_Environment::$lastRule && Less_Parser::$options['compress'] ) ) ? "" : ";" ), |
| 40 |
$this->currentFileInfo, $this->index ); |
| 41 |
} |
| 42 |
|
| 43 |
public function compile( $env ) { |
| 44 |
return $this; |
| 45 |
} |
| 46 |
|
| 47 |
public function makeImportant() { |
| 48 |
$new = new self( $this->name, $this->value, $this->index, $this->currentFileInfo ); |
| 49 |
$new->important = ' !important'; |
| 50 |
return $new; |
| 51 |
} |
| 52 |
|
| 53 |
} |