From 650694f18fdd8f6f203f45df32572e51a70d1cb7 Mon Sep 17 00:00:00 2001 From: David Woloszyn Date: Thu, 20 Oct 2022 09:31:34 +1100 Subject: [PATCH] MDL-75475 lib: Applied PHP CSS Parser patches --- lib/php-css-parser/CSSList/CSSList.php | 15 ++++++++++++++- lib/php-css-parser/Rule/Rule.php | 1 - 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/php-css-parser/CSSList/CSSList.php b/lib/php-css-parser/CSSList/CSSList.php index 946740a4999..e24caeeb6f3 100644 --- a/lib/php-css-parser/CSSList/CSSList.php +++ b/lib/php-css-parser/CSSList/CSSList.php @@ -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. * diff --git a/lib/php-css-parser/Rule/Rule.php b/lib/php-css-parser/Rule/Rule.php index c1ea6df74e5..52b97f38e15 100644 --- a/lib/php-css-parser/Rule/Rule.php +++ b/lib/php-css-parser/Rule/Rule.php @@ -106,7 +106,6 @@ class Rule implements Renderable, Commentable while ($oParserState->comes(';')) { $oParserState->consume(';'); } - $oParserState->consumeWhiteSpace(); return $oRule; }