Allow CSS identifiers to start with an underscore.

This commit is contained in:
Yorick Peterse 2014-11-05 00:37:30 +01:00
parent f1316c50fb
commit 61801fe562
2 changed files with 5 additions and 1 deletions

View File

@ -155,7 +155,7 @@ module Oga
# Identifiers are used for element and attribute names. Identifiers have
# to start with a letter.
identifier = '*' | [a-zA-Z]+ [a-zA-Z\-_0-9]*;
identifier = '*' | [a-zA-Z_]+ [a-zA-Z\-_0-9]*;
action emit_identifier {
emit(:T_IDENT, ts, te)

View File

@ -6,6 +6,10 @@ describe Oga::CSS::Lexer do
lex_css('h3').should == [[:T_IDENT, 'h3']]
end
example 'lex a simple path starting with an underscore' do
lex_css('_h3').should == [[:T_IDENT, '_h3']]
end
example 'lex a path with two members' do
lex_css('div h3').should == [
[:T_IDENT, 'div'],