diff --git a/lib/Sabberworm/CSS/CSSList/CSSList.php b/lib/Sabberworm/CSS/CSSList/CSSList.php index bc90460b..84113058 100644 --- a/lib/Sabberworm/CSS/CSSList/CSSList.php +++ b/lib/Sabberworm/CSS/CSSList/CSSList.php @@ -31,6 +31,10 @@ public function getLineNo() { return $this->iLineNo; } + public function prepend($oItem) { + array_unshift($this->aContents, $oItem); + } + public function append($oItem) { $this->aContents[] = $oItem; } @@ -48,6 +52,19 @@ public function remove($oItemToRemove) { return false; } + /** + * Replaces an item from the CSS list. + * @param RuleSet|Import|Charset|CSSList $oItemToRemove May be a RuleSet (most likely a DeclarationBlock), a Import, a Charset or another CSSList (most likely a MediaQuery) + */ + public function replace($oOldItem, $oNewItem) { + $iKey = array_search($oOldItem, $this->aContents, true); + if ($iKey !== false) { + array_splice($this->aContents, $iKey, 1, $oNewItem); + return true; + } + return false; + } + /** * Set the contents. * @param array $aContents Objects to set as content.