Skip to content

Commit b27717d

Browse files
committed
Consume the closing ) for calc(), so additional modifiers like !important can be parsed properly
1 parent 90534d9 commit b27717d

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

lib/Sabberworm/CSS/Parser.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,8 @@ private function parseCalcValue() {
530530
$this->consumeWhiteSpace();
531531
$this->consume('(');
532532
$aArguments = $this->parseValue(array('+', '-', '*', '/', ' '), '\Sabberworm\CSS\Value\CalcRuleValueList');
533+
$this->consumeWhiteSpace();
534+
$this->consume(')');
533535
return new CalcFunction($func, $aArguments, ',', $this->iLineNo);
534536
}
535537

tests/Sabberworm/CSS/ParserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ function testUrlInFile() {
390390
function testCalcInFile() {
391391
$oDoc = $this->parsedStructureForFile('calc', Settings::create()->withMultibyteSupport(true));
392392
$sExpected = 'div {width: calc(100% / 4);}
393-
div {height: -webkit-calc(9 / 16 * 100%);}';
393+
div {height: -webkit-calc(9 / 16 * 100%) !important;}';
394394
$this->assertSame($sExpected, $oDoc->render());
395395
}
396396

tests/files/calc.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
div { width: calc(100% / 4); }
22
div {
3-
height: -webkit-calc(9/16 * 100%);
3+
height: -webkit-calc(9/16 * 100%)!important;
44
}

0 commit comments

Comments
 (0)