Ordering of properties after expanding shorthands is wrong
Idrinth opened this issue · comments
Björn Büttner commented
.some-rule{
padding:5px;
padding-top: 20px
}
leads to
array(5) {
[0]=>
string(18) "padding-top: 20px;"
[1]=>
string(17) "padding-top: 5px;"
[2]=>
string(19) "padding-right: 5px;"
[3]=>
string(20) "padding-bottom: 5px;"
[4]=>
string(18) "padding-left: 5px;"
}
Giving padding-top a 5px instead of the expected 20px when getting rules as assoc. Most likely related to that creating shorthands leads to the original input instead of merging the padding rules.
Björn Büttner commented
looks like that can be fixed with some tiny changes - if I find the time tonight I'll add a pull request:
In addRule
if ($oSibling !== null) {
$iSiblingPos = array_search($oSibling, $this->aRules[$sRule], true);
if ($iSiblingPos !== false) {
$iPosition = $iSiblingPos;
} elseif ($sRule !== $oSibling->getRule()) {
$ruleKeys = array_keys($this->aRules);
$pos = array_search($oSibling->getRule(), $ruleKeys, true);
if ($pos !== false && $pos < array_search($oRule->getRule(), $ruleKeys, true)) {
$iPosition = 0;
}
}
}
And then passing in the original Rule as a sibling.
Björn Büttner commented
Seems the master is changed a lot in comparison to the latest release - not yet sure how to do this now.