MDL-75475 lib: Applied PHP CSS Parser patches

This commit is contained in:
David Woloszyn 2022-10-20 09:31:34 +11:00
parent c8ee3c9051
commit 650694f18f
2 changed files with 14 additions and 2 deletions

View File

@ -89,7 +89,6 @@ abstract class CSSList implements Renderable, Commentable
$oListItem->setComments($comments);
$oList->append($oListItem);
}
$oParserState->consumeWhiteSpace();
}
if (!$bIsRoot && !$bLenientParsing) {
throw new SourceException("Unexpected end of document", $oParserState->currentLine());
@ -283,6 +282,20 @@ abstract class CSSList implements Renderable, Commentable
$this->aContents[] = $oItem;
}
/**
* Insert an item before its sibling.
*
* @param mixed $oItem The item.
* @param mixed $oSibling The sibling.
*/
public function insert($oItem, $oSibling) {
$iIndex = array_search($oSibling, $this->aContents);
if ($iIndex === false) {
return $this->append($oItem);
}
array_splice($this->aContents, $iIndex, 0, array($oItem));
}
/**
* Splices the list of contents.
*

View File

@ -106,7 +106,6 @@ class Rule implements Renderable, Commentable
while ($oParserState->comes(';')) {
$oParserState->consume(';');
}
$oParserState->consumeWhiteSpace();
return $oRule;
}