Skip to content

Commit

Permalink
#176 - Fixed rule order sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
TRPB committed Dec 12, 2017
1 parent 5588a89 commit 4d3d6f6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Parser/Sheet.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ private function parseTokens($indexStart) {
if ($processing = $this->processingInstructions($token, count($this->rules)+$indexStart)) {
$this->rules = array_merge($this->rules, $processing);
}
else if ($token['type'] !== Tokenizer::NEW_LINE) $this->addRules($token, $indexStart);
else if ($token['type'] !== Tokenizer::NEW_LINE) $this->addRules($token, $indexStart++);
}

return $this->rules;
Expand All @@ -70,7 +70,7 @@ private function CssToRules($selector, $index, $properties, $line) {
$rules = [];
foreach ($parts as $part) {
$serialized = serialize($part->removeLine());
$rules[$serialized] = new \Transphporm\Rule($this->xPath->getXpath($part), $this->xPath->getPseudo($part), $this->xPath->getDepth($part), $index++, $this->file, $line);
$rules[$serialized] = new \Transphporm\Rule($this->xPath->getXpath($part), $this->xPath->getPseudo($part), $this->xPath->getDepth($part), $index, $this->file, $line);
$rules[$serialized]->properties = $properties;
}
return $rules;
Expand Down
26 changes: 26 additions & 0 deletions tests/TransphpormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1817,6 +1817,32 @@ public function testLess() {

}

public function testFillSelect() {
$xml = '<select><option></option></select>';

$tss = 'select option {repeat: data(options); }
select option { content: iteration(); }
select option:attr(value) { content: key(); }
';

$template = new Builder($xml, $tss);

$data = ['options' => [
'01' => 'January',
'02' => 'Februrary',
'03' => 'March'
]];

$output = $template->output($data)->body;

$this->assertEquals($this->stripTabs('<select><option value="01">January</option>
<option value="02">Februrary</option>
<option value="03">March</option></select>'), $this->stripTabs($output));

}



}


Expand Down

0 comments on commit 4d3d6f6

Please sign in to comment.