Skip to content

Commit 1cf180d

Browse files
committed
Implement isVisble for Less_Tree_Anonymous
We have made the nodeVisible property to be slightly different than that of less.js. Less.js defaults to null but we can't default to null because we don't have a full implementation of the visibility feature. So for now we would just assume that all nodes defaults to true and implement the full visibility feature in a later task. Bug: T393383 Change-Id: I5b203b24fd208781a25b3551be535263464eeb57
1 parent e2e13bf commit 1cf180d

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

lib/Less/Tree.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ class Less_Tree {
1111
public $extendOnEveryPath;
1212
/** @var Less_Tree_Extend[] */
1313
public $allExtends;
14+
/**
15+
* This is set to true to ensure visibility
16+
* for all except Less_Tree_Anonymous where we decide
17+
* if the the node should be visible or not
18+
*
19+
* @var bool
20+
*/
21+
public $nodeVisible = true;
1422

1523
/**
1624
* @var Less_Parser
@@ -201,4 +209,11 @@ public static function __set_state( $args ) {
201209
return $obj;
202210
}
203211

212+
/**
213+
* @see less-3.13.1.js#Node.prototype.isVisible
214+
*/
215+
public function isVisible() {
216+
return $this->nodeVisible;
217+
}
218+
204219
}

lib/Less/Tree/Anonymous.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ public function isRulesetLike() {
5959
* @see less-3.13.1.js#Anonymous.prototype.genCSS
6060
*/
6161
public function genCSS( $output ) {
62-
// TODO: When we implement $visibilityInfo, store this result in-class
63-
$nodeVisible = $this->value !== "" && $this->value !== 0;
64-
if ( $nodeVisible ) {
62+
$this->nodeVisible = $this->value !== "" && $this->value !== 0;
63+
if ( $this->nodeVisible ) {
6564
$output->add( $this->value, $this->currentFileInfo, $this->index, $this->mapLines );
6665
}
6766
}

lib/Less/Tree/Ruleset.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -582,7 +582,7 @@ public function genCSS( $output ) {
582582

583583
Less_Environment::$lastRule = $currentLastRule;
584584

585-
if ( !Less_Environment::$lastRule ) {
585+
if ( !Less_Environment::$lastRule && $rule->isVisible() ) {
586586
$output->add( $tabRuleStr );
587587
} else {
588588
Less_Environment::$lastRule = false;

0 commit comments

Comments
 (0)