Skip to content

Commit 751a8bc

Browse files
committed
Before reparsing a selector that need a double pass, you should revert [self] to & #368
1 parent fccb074 commit 751a8bc

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

src/Compiler.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,6 +1359,7 @@ protected function evalSelectors($selectors)
13591359

13601360
// after evaluating interpolates, we might need a second pass
13611361
if ($this->shouldEvaluate) {
1362+
$selectors = $this->revertSelfSelector($selectors);
13621363
$buffer = $this->collapseSelectors($selectors);
13631364
$parser = $this->parserFactory(__METHOD__);
13641365

@@ -1440,6 +1441,24 @@ function ($value, $key) use (&$output) {
14401441
return implode(', ', $parts);
14411442
}
14421443

1444+
/**
1445+
* Parse down the selector and revert [self] to "&" before a reparsing
1446+
* @param array $selectors
1447+
* @return array
1448+
*/
1449+
protected function revertSelfSelector($selectors) {
1450+
foreach ($selectors as &$part) {
1451+
if (is_array($part)) {
1452+
if ($part === [Type::T_SELF]) {
1453+
$part = '&';
1454+
} else {
1455+
$part = $this->revertSelfSelector($part);
1456+
}
1457+
}
1458+
}
1459+
return $selectors;
1460+
}
1461+
14431462
/**
14441463
* Flatten selector single; joins together .classes and #ids
14451464
*

0 commit comments

Comments
 (0)