Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/Sabberworm/CSS/CSSList/CSSList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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.
Expand Down