Skip to content

Commit 46b7cb0

Browse files
authored
Merge pull request #695 from Cerdic/Issue/leafo/368
Before reparsing a selector that need a double pass,
2 parents 151009f + 751a8bc commit 46b7cb0

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
@@ -1358,6 +1358,7 @@ protected function evalSelectors($selectors)
13581358

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

@@ -1470,6 +1471,24 @@ function ($value, $key) use (&$compound) {
14701471
return $parts;
14711472
}
14721473

1474+
/**
1475+
* Parse down the selector and revert [self] to "&" before a reparsing
1476+
* @param array $selectors
1477+
* @return array
1478+
*/
1479+
protected function revertSelfSelector($selectors) {
1480+
foreach ($selectors as &$part) {
1481+
if (is_array($part)) {
1482+
if ($part === [Type::T_SELF]) {
1483+
$part = '&';
1484+
} else {
1485+
$part = $this->revertSelfSelector($part);
1486+
}
1487+
}
1488+
}
1489+
return $selectors;
1490+
}
1491+
14731492
/**
14741493
* Flatten selector single; joins together .classes and #ids
14751494
*

0 commit comments

Comments
 (0)