diff --git a/lib/oga/css/parser.y b/lib/oga/css/parser.y index 43382ca..3d91e78 100644 --- a/lib/oga/css/parser.y +++ b/lib/oga/css/parser.y @@ -70,8 +70,8 @@ rule ; class - : class_name { s(:class, val[0]) } - | path_member class_name { s(:class, val[1], val[0]) } + : class_name { s(:class, nil, val[0]) } + | path_member class_name { s(:class, val[0], val[1]) } ; class_name @@ -79,8 +79,8 @@ rule ; id - : id_name { s(:id, val[0]) } - | path_member id_name { s(:id, val[1], val[0]) } + : id_name { s(:id, nil, val[0]) } + | path_member id_name { s(:id, val[0], val[1]) } ; id_name diff --git a/spec/oga/css/parser/axes_spec.rb b/spec/oga/css/parser/axes_spec.rb index e402d0a..64a0572 100644 --- a/spec/oga/css/parser/axes_spec.rb +++ b/spec/oga/css/parser/axes_spec.rb @@ -22,7 +22,7 @@ describe Oga::CSS::Parser do parse_css('x > foo#bar').should == s( :child, s(:test, nil, 'x'), - s(:id, 'bar', s(:test, nil, 'foo')) + s(:id, s(:test, nil, 'foo'), 'bar') ) end @@ -30,7 +30,7 @@ describe Oga::CSS::Parser do parse_css('x > foo.bar').should == s( :child, s(:test, nil, 'x'), - s(:class, 'bar', s(:test, nil, 'foo')) + s(:class, s(:test, nil, 'foo'), 'bar') ) end diff --git a/spec/oga/css/parser/classes_spec.rb b/spec/oga/css/parser/classes_spec.rb index bb362b6..c879584 100644 --- a/spec/oga/css/parser/classes_spec.rb +++ b/spec/oga/css/parser/classes_spec.rb @@ -3,30 +3,30 @@ require 'spec_helper' describe Oga::CSS::Parser do context 'classes' do example 'parse a class selector' do - parse_css('.foo').should == s(:class, 'foo') + parse_css('.foo').should == s(:class, nil, 'foo') end example 'parse a selector for an element with a class' do - parse_css('foo.bar').should == s(:class, 'bar', s(:test, nil, 'foo')) + parse_css('foo.bar').should == s(:class, s(:test, nil, 'foo'), 'bar') end example 'parse a selector using multiple classes' do - parse_css('.foo.bar').should == s(:class, 'bar', s(:class, 'foo')) + parse_css('.foo.bar').should == s(:class, s(:class, nil, 'foo'), 'bar') end example 'parse a selector using a class and an ID' do - parse_css('#foo.bar').should == s(:class, 'bar', s(:id, 'foo')) + parse_css('#foo.bar').should == s(:class, s(:id, nil, 'foo'), 'bar') end example 'parse a selector using a class and a pseudo class' do - parse_css('.foo:root').should == s(:pseudo, 'root', s(:class, 'foo')) + parse_css('.foo:root').should == s(:pseudo, 'root', s(:class, nil, 'foo')) end example 'parse a selector using a pseudo class and a class' do parse_css('x:root.foo').should == s( :class, - 'foo', - s(:pseudo, 'root', s(:test, nil, 'x')) + s(:pseudo, 'root', s(:test, nil, 'x')), + 'foo' ) end end diff --git a/spec/oga/css/parser/ids_spec.rb b/spec/oga/css/parser/ids_spec.rb index aeb0744..d93ea6e 100644 --- a/spec/oga/css/parser/ids_spec.rb +++ b/spec/oga/css/parser/ids_spec.rb @@ -3,26 +3,26 @@ require 'spec_helper' describe Oga::CSS::Parser do context 'IDs' do example 'parse an ID selector' do - parse_css('#foo').should == s(:id, 'foo') + parse_css('#foo').should == s(:id, nil, 'foo') end example 'parse a selector for an element with an ID' do - parse_css('foo#bar').should == s(:id, 'bar', s(:test, nil, 'foo')) + parse_css('foo#bar').should == s(:id, s(:test, nil, 'foo'), 'bar') end example 'parse a selector using an ID and a class' do - parse_css('.foo#bar').should == s(:id, 'bar', s(:class, 'foo')) + parse_css('.foo#bar').should == s(:id, s(:class, nil, 'foo'), 'bar') end example 'parse a selector using an ID and a pseudo class' do - parse_css('#foo:root').should == s(:pseudo, 'root', s(:id, 'foo')) + parse_css('#foo:root').should == s(:pseudo, 'root', s(:id, nil, 'foo')) end example 'parse a selector using a pseudo class and an ID' do parse_css('x:root#foo').should == s( :id, - 'foo', - s(:pseudo, 'root', s(:test, nil, 'x')) + s(:pseudo, 'root', s(:test, nil, 'x')), + 'foo' ) end end