diff --git a/src/Symfony/Component/CssSelector/CssSelector.php b/src/Symfony/Component/CssSelector/CssSelector.php index ed74df3fb752..86f81ebc72b7 100644 --- a/src/Symfony/Component/CssSelector/CssSelector.php +++ b/src/Symfony/Component/CssSelector/CssSelector.php @@ -153,6 +153,11 @@ private function parseSelector($stream) } elseif (in_array($peek, array('+', '>', '~'))) { // A combinator $combinator = (string) $stream->next(); + + // Ignore optional whitespace after a combinator + while (' ' == $stream->peek()) { + $stream->next(); + } } else { $combinator = ' '; } diff --git a/tests/Symfony/Tests/Component/CssSelector/CssSelectorTest.php b/tests/Symfony/Tests/Component/CssSelector/CssSelectorTest.php index 23bd5a697dfa..9165f74f9186 100644 --- a/tests/Symfony/Tests/Component/CssSelector/CssSelectorTest.php +++ b/tests/Symfony/Tests/Component/CssSelector/CssSelectorTest.php @@ -64,6 +64,8 @@ public function getCssSelectors() array('h1 .foo', "h1/descendant::*[contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"), array('h1 #foo', "h1/descendant::*[@id = 'foo']"), array('h1 [class*=foo]', "h1/descendant::*[contains(@class, 'foo')]"), + array('div>.foo', "div/*[contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"), + array('div > .foo', "div/*[contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"), ); } }