Skip to content

Commit cc7ac45

Browse files
authored
Merge pull request #177 from raxbg/fix/csslist_replace
Fix CSSList::replace with object as the new value
2 parents c4509f5 + 0d8f3bd commit cc7ac45

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/Sabberworm/CSS/CSSList/CSSList.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,14 @@ public function remove($oItemToRemove) {
238238
* Replaces an item from the CSS list.
239239
* @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)
240240
*/
241-
public function replace($oOldItem, $oNewItem) {
241+
public function replace($oOldItem, $mNewItem) {
242242
$iKey = array_search($oOldItem, $this->aContents, true);
243243
if ($iKey !== false) {
244-
array_splice($this->aContents, $iKey, 1, $oNewItem);
244+
if (is_array($mNewItem)) {
245+
array_splice($this->aContents, $iKey, 1, $mNewItem);
246+
} else {
247+
array_splice($this->aContents, $iKey, 1, array($mNewItem));
248+
}
245249
return true;
246250
}
247251
return false;

0 commit comments

Comments
 (0)