diff --git a/src/Value/Size.php b/src/Value/Size.php index 9329f15b..36a32381 100644 --- a/src/Value/Size.php +++ b/src/Value/Size.php @@ -77,9 +77,16 @@ public static function parse(ParserState $oParserState, $bIsColorComponent = fal if ($oParserState->comes('-')) { $sSize .= $oParserState->consume('-'); } - while (is_numeric($oParserState->peek()) || $oParserState->comes('.')) { + while (is_numeric($oParserState->peek()) || $oParserState->comes('.') || $oParserState->comes('e', true)) { if ($oParserState->comes('.')) { $sSize .= $oParserState->consume('.'); + } elseif ($oParserState->comes('e', true)) { + $sLookahead = $oParserState->peek(1, 1); + if (is_numeric($sLookahead) || $sLookahead === '+' || $sLookahead === '-') { + $sSize .= $oParserState->consume(2); + } else { + break; // Reached the unit part of the number like "em" or "ex" + } } else { $sSize .= $oParserState->consume(1); } diff --git a/tests/ParserTest.php b/tests/ParserTest.php index 5e2a3101..012ab667 100644 --- a/tests/ParserTest.php +++ b/tests/ParserTest.php @@ -1171,6 +1171,21 @@ public function largeSizeValuesInFile() self::assertSame($sExpected, $oDoc->render()); } + /** + * @test + */ + public function scientificNotationSizeValuesInFile() + { + $oDoc = $this->parsedStructureForFile( + 'scientific-notation-numbers', + Settings::create()->withMultibyteSupport(false) + ); + $sExpected = '' + . 'body {background-color: rgba(62,174,151,3041820656523200167936);' + . 'z-index: .030418206565232;font-size: 1em;top: 192.3478px;}'; + self::assertSame($sExpected, $oDoc->render()); + } + /** * @test */ diff --git a/tests/fixtures/scientific-notation-numbers.css b/tests/fixtures/scientific-notation-numbers.css new file mode 100644 index 00000000..cbed2337 --- /dev/null +++ b/tests/fixtures/scientific-notation-numbers.css @@ -0,0 +1,6 @@ +body { + background-color: rgba(62,174,151,3.0418206565232E+21); + z-index: 3.0418206565232E-2; + font-size: 1em; + top: 1.923478e2px; +}