Swap child order of CSS class and id nodes.

This makes it easier to transform the AST at a later stage.
This commit is contained in:
Yorick Peterse 2014-10-16 23:13:54 +02:00
parent 7ccd685acb
commit 63d27fa709
4 changed files with 19 additions and 19 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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