Skip to content

Commit ed580dc

Browse files
author
Frederic Massart
committed
Use CSSFunction for Microsoft old-style filter
Tested on down to IE8 and confirmed that string arguments can be wrapped in single quotes, double quotes, or nothing.
1 parent d5bf1ce commit ed580dc

File tree

3 files changed

+12
-36
lines changed

3 files changed

+12
-36
lines changed

lib/Sabberworm/CSS/Parser.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Sabberworm\CSS\Value\Color;
2020
use Sabberworm\CSS\Value\URL;
2121
use Sabberworm\CSS\Value\CSSString;
22-
use Sabberworm\CSS\Value\Statement;
2322
use Sabberworm\CSS\Rule\Rule;
2423
use Sabberworm\CSS\Parsing\UnexpectedTokenException;
2524
use Sabberworm\CSS\Comment\Comment;
@@ -437,7 +436,7 @@ private function parsePrimitiveValue() {
437436
$oValue = $this->parseURLValue();
438437
} else if ($this->comes("'") || $this->comes('"')) {
439438
$oValue = $this->parseStringValue();
440-
} else if ($this->comes("progid:")) {
439+
} else if ($this->comes("progid:") && $this->oParserSettings->bLenientParsing) {
441440
$oValue = $this->parseMicrosoftFilter();
442441
} else {
443442
$oValue = $this->parseIdentifier(true, false);
@@ -500,8 +499,9 @@ private function parseColorValue() {
500499
}
501500

502501
private function parseMicrosoftFilter() {
503-
$sStatement = $this->consumeUntil(')', true, true);
504-
return new Statement($sStatement, $this->iLineNo);
502+
$sFunction = $this->consumeUntil('(', false, true);
503+
$aArguments = $this->parseValue(array(',', '='));
504+
return new CSSFunction($sFunction, $aArguments, ',', $this->iLineNo);
505505
}
506506

507507
private function parseURLValue() {

lib/Sabberworm/CSS/Value/Statement.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

tests/Sabberworm/CSS/ParserTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,9 +583,16 @@ function testTopLevelCommentExtracting() {
583583
$this->assertEquals("Find Me!", $comments[0]->getComment());
584584
}
585585

586+
/**
587+
* @expectedException Sabberworm\CSS\Parsing\UnexpectedTokenException
588+
*/
589+
function testMicrosoftFilterStrictParsing() {
590+
$oDoc = $this->parsedStructureForFile('ms-filter', Settings::create()->beStrict());
591+
}
592+
586593
function testMicrosoftFilterParsing() {
587594
$oDoc = $this->parsedStructureForFile('ms-filter');
588-
$sExpected = ".test {filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#80000000', endColorstr='#00000000', GradientType=1);}";
595+
$sExpected = ".test {filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=\"#80000000\",endColorstr=\"#00000000\",GradientType=1);}";
589596
$this->assertSame($sExpected, $oDoc->render());
590597
}
591598
}

0 commit comments

Comments
 (0)