PHP-CSS-Parser
PHP-CSS-Parser copied to clipboard
Support for inserting an item in a CSSList
For your consideration.
I like the idea, but the method name insert
suggests that it must have a parameter for position: before or after. Also what if we just map this to the existing replace
? Suggestion:
public function insert($oItem, $oSibling, $sPosition = 'before') {
$iIndex = array_search($oSibling, $this->aContents);
if ($iIndex === false) {
return $this->append($oItem);
} else if ($sPosition === 'before') {
$this->replace($oItem, array($oSibling, $oItem));
} else {
$this->replace($oItem, array($oItem, $oSibling));
}
}
As there was no progress on this for the last five years I created #545.
@oliverklee I think this can now be closed.
Indeed it can. Thanks for implementing/finishing this, @ziegenberg! :heart:
Implemented in #545.