Skip to content

Commit

Permalink
[CssSelector] fixed numeric attribute issue
Browse files Browse the repository at this point in the history
  • Loading branch information
jfsimon committed Jan 7, 2014
1 parent 0ebf99b commit 613535a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Symfony/Component/CssSelector/Parser/Parser.php
Expand Up @@ -378,6 +378,11 @@ private function parseAttributeNode(Node\NodeInterface $selector, TokenStream $s
$stream->skipWhitespace();
$value = $stream->getNext();

if ($value->isNumber()) {
// if the value is a number, it's casted into a string
$value = new Token(Token::TYPE_STRING, (string) $value->getValue(), $value->getPosition());
}

if (!($value->isIdentifier() || $value->isString())) {
throw SyntaxErrorException::unexpectedToken('string or identifier', $value);
}
Expand Down
Expand Up @@ -133,6 +133,7 @@ public function getParserTestData()
array('div#foobar', array('Hash[Element[div]#foobar]')),
array('div:not(div.foo)', array('Negation[Element[div]:not(Class[Element[div].foo])]')),
array('td ~ th', array('CombinedSelector[Element[td] ~ Element[th]]')),
array('.foo[data-bar][data-baz=0]', array("Attribute[Attribute[Class[Element[*].foo][data-bar]][data-baz = '0']]")),
);
}

Expand Down

0 comments on commit 613535a

Please sign in to comment.