Skip to content

Commit 812fbe6

Browse files
committed
Pseudo classes cannot have a space after the : char
1 parent eeece76 commit 812fbe6

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

src/Property/Selector.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Selector
4646
/ix';
4747

4848
/**
49-
* regexp for specificity calculations
49+
* regexp for validity verifications
5050
*
5151
* @var string
5252
*/
@@ -77,7 +77,7 @@ class Selector
7777
*/
7878
public static function isValid($sSelector)
7979
{
80-
return preg_match(static::SELECTOR_VALIDATION_RX, $sSelector);
80+
return preg_match(static::SELECTOR_VALIDATION_RX, $sSelector) && strpos($sSelector, ': ') === false;
8181
}
8282

8383
/**

tests/ParserTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,11 @@ public function invalidSelectorsInFile()
742742
html[dir="rtl"] .super-menu > li:last-of-type {border-left-width: 0;}}
743743
body {background-color: red;}';
744744
self::assertSame($sExpected, $oDoc->render());
745+
746+
$oDoc = self::parsedStructureForFile('invalid-selectors-3', Settings::create()->withMultibyteSupport(true));
747+
$sExpected = 'body, div :hover {color: green;}
748+
div {color: blue;}';
749+
self::assertSame($sExpected, $oDoc->render());
745750
}
746751

747752
/**
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
body, div: hover {
2+
color: green;
3+
}
4+
5+
body, div : hover {
6+
color: green;
7+
}
8+
9+
body, div :hover {
10+
color: green;
11+
}
12+
13+
div {
14+
color: blue;
15+
}

0 commit comments

Comments
 (0)