[CssSelector] ignored an optional whitespace after a combinator

This commit is contained in:
Fabien Potencier 2012-05-13 09:14:40 +02:00
parent d34383f10b
commit c642a5ec19
2 changed files with 7 additions and 0 deletions

View File

@ -153,6 +153,11 @@ class CssSelector
} elseif (in_array($peek, array('+', '>', '~'))) {
// A combinator
$combinator = (string) $stream->next();
// Ignore optional whitespace after a combinator
while (' ' == $stream->peek()) {
$stream->next();
}
} else {
$combinator = ' ';
}

View File

@ -64,6 +64,8 @@ class CssSelectorTest extends \PHPUnit_Framework_TestCase
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 ')]"),
);
}
}