Skip to content

Commit 4d3d6f6

Browse files
committed
#176 - Fixed rule order sorting
1 parent 5588a89 commit 4d3d6f6

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/Parser/Sheet.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ private function parseTokens($indexStart) {
4545
if ($processing = $this->processingInstructions($token, count($this->rules)+$indexStart)) {
4646
$this->rules = array_merge($this->rules, $processing);
4747
}
48-
else if ($token['type'] !== Tokenizer::NEW_LINE) $this->addRules($token, $indexStart);
48+
else if ($token['type'] !== Tokenizer::NEW_LINE) $this->addRules($token, $indexStart++);
4949
}
5050

5151
return $this->rules;
@@ -70,7 +70,7 @@ private function CssToRules($selector, $index, $properties, $line) {
7070
$rules = [];
7171
foreach ($parts as $part) {
7272
$serialized = serialize($part->removeLine());
73-
$rules[$serialized] = new \Transphporm\Rule($this->xPath->getXpath($part), $this->xPath->getPseudo($part), $this->xPath->getDepth($part), $index++, $this->file, $line);
73+
$rules[$serialized] = new \Transphporm\Rule($this->xPath->getXpath($part), $this->xPath->getPseudo($part), $this->xPath->getDepth($part), $index, $this->file, $line);
7474
$rules[$serialized]->properties = $properties;
7575
}
7676
return $rules;

tests/TransphpormTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,6 +1817,32 @@ public function testLess() {
18171817

18181818
}
18191819

1820+
public function testFillSelect() {
1821+
$xml = '<select><option></option></select>';
1822+
1823+
$tss = 'select option {repeat: data(options); }
1824+
select option { content: iteration(); }
1825+
select option:attr(value) { content: key(); }
1826+
';
1827+
1828+
$template = new Builder($xml, $tss);
1829+
1830+
$data = ['options' => [
1831+
'01' => 'January',
1832+
'02' => 'Februrary',
1833+
'03' => 'March'
1834+
]];
1835+
1836+
$output = $template->output($data)->body;
1837+
1838+
$this->assertEquals($this->stripTabs('<select><option value="01">January</option>
1839+
<option value="02">Februrary</option>
1840+
<option value="03">March</option></select>'), $this->stripTabs($output));
1841+
1842+
}
1843+
1844+
1845+
18201846
}
18211847

18221848

0 commit comments

Comments
 (0)