Skip to content

Commit

Permalink
[CssSelector] ignored an optional whitespace after a combinator
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed May 13, 2012
1 parent d34383f commit c642a5e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Symfony/Component/CssSelector/CssSelector.php
Expand Up @@ -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 = ' ';
}
Expand Down
2 changes: 2 additions & 0 deletions tests/Symfony/Tests/Component/CssSelector/CssSelectorTest.php
Expand Up @@ -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 ')]"),
);
}
}

0 comments on commit c642a5e

Please sign in to comment.