Remove :axis CSS node types.
The various axes are now simply their own node types.
This commit is contained in:
parent
ed0cd7826e
commit
d9a4221a0a
|
@ -103,21 +103,15 @@ rule
|
|||
|
||||
axis
|
||||
# x > y
|
||||
: path_member T_CHILD path_member
|
||||
{
|
||||
s(:axis, 'child', val[0], val[2])
|
||||
}
|
||||
: path_member T_CHILD path_member { s(:child, val[0], val[2]) }
|
||||
|
||||
# x + y
|
||||
| path_member T_FOLLOWING path_member
|
||||
{
|
||||
s(:axis, 'following', val[0], val[2])
|
||||
}
|
||||
| path_member T_FOLLOWING path_member { s(:following, val[0], val[2]) }
|
||||
|
||||
# x ~ y
|
||||
| path_member T_FOLLOWING_DIRECT path_member
|
||||
{
|
||||
s(:axis, 'following-direct', val[0], val[2])
|
||||
s(:following_direct, val[0], val[2])
|
||||
}
|
||||
;
|
||||
|
||||
|
|
|
@ -4,8 +4,7 @@ describe Oga::CSS::Parser do
|
|||
context 'axes' do
|
||||
example 'parse the > axis' do
|
||||
parse_css('x > y').should == s(
|
||||
:axis,
|
||||
'child',
|
||||
:child,
|
||||
s(:test, nil, 'x'),
|
||||
s(:test, nil, 'y')
|
||||
)
|
||||
|
@ -13,17 +12,15 @@ describe Oga::CSS::Parser do
|
|||
|
||||
example 'parse the > axis called on another > axis' do
|
||||
parse_css('a > b > c').should == s(
|
||||
:axis,
|
||||
'child',
|
||||
s(:axis, 'child', s(:test, nil, 'a'), s(:test, nil, 'b')),
|
||||
:child,
|
||||
s(:child, s(:test, nil, 'a'), s(:test, nil, 'b')),
|
||||
s(:test, nil, 'c')
|
||||
)
|
||||
end
|
||||
|
||||
example 'parse an > axis followed by an element with an ID' do
|
||||
parse_css('x > foo#bar').should == s(
|
||||
:axis,
|
||||
'child',
|
||||
:child,
|
||||
s(:test, nil, 'x'),
|
||||
s(:id, 'bar', s(:test, nil, 'foo'))
|
||||
)
|
||||
|
@ -31,8 +28,7 @@ describe Oga::CSS::Parser do
|
|||
|
||||
example 'parse an > axis followed by an element with a class' do
|
||||
parse_css('x > foo.bar').should == s(
|
||||
:axis,
|
||||
'child',
|
||||
:child,
|
||||
s(:test, nil, 'x'),
|
||||
s(:class, 'bar', s(:test, nil, 'foo'))
|
||||
)
|
||||
|
@ -40,8 +36,7 @@ describe Oga::CSS::Parser do
|
|||
|
||||
example 'parse the + axis' do
|
||||
parse_css('x + y').should == s(
|
||||
:axis,
|
||||
'following-direct',
|
||||
:following_direct,
|
||||
s(:test, nil, 'x'),
|
||||
s(:test, nil, 'y')
|
||||
)
|
||||
|
@ -49,17 +44,15 @@ describe Oga::CSS::Parser do
|
|||
|
||||
example 'parse the + axis called on another + axis' do
|
||||
parse_css('a + b + c').should == s(
|
||||
:axis,
|
||||
'following-direct',
|
||||
s(:axis, 'following-direct', s(:test, nil, 'a'), s(:test, nil, 'b')),
|
||||
:following_direct,
|
||||
s(:following_direct, s(:test, nil, 'a'), s(:test, nil, 'b')),
|
||||
s(:test, nil, 'c')
|
||||
)
|
||||
end
|
||||
|
||||
example 'parse the ~ axis' do
|
||||
parse_css('x ~ y').should == s(
|
||||
:axis,
|
||||
'following',
|
||||
:following,
|
||||
s(:test, nil, 'x'),
|
||||
s(:test, nil, 'y')
|
||||
)
|
||||
|
@ -68,24 +61,22 @@ describe Oga::CSS::Parser do
|
|||
example 'parse the ~ axis followed by another node test' do
|
||||
parse_css('x ~ y z').should == s(
|
||||
:path,
|
||||
s(:axis, 'following', s(:test, nil, 'x'), s(:test, nil, 'y')),
|
||||
s(:following, s(:test, nil, 'x'), s(:test, nil, 'y')),
|
||||
s(:test, nil, 'z')
|
||||
)
|
||||
end
|
||||
|
||||
example 'parse the ~ axis called on another ~ axis' do
|
||||
parse_css('a ~ b ~ c').should == s(
|
||||
:axis,
|
||||
'following',
|
||||
s(:axis, 'following', s(:test, nil, 'a'), s(:test, nil, 'b')),
|
||||
:following,
|
||||
s(:following, s(:test, nil, 'a'), s(:test, nil, 'b')),
|
||||
s(:test, nil, 'c')
|
||||
)
|
||||
end
|
||||
|
||||
example 'parse a pseudo class followed by the ~ axis' do
|
||||
parse_css('x:root ~ a').should == s(
|
||||
:axis,
|
||||
'following',
|
||||
:following,
|
||||
s(:pseudo, 'root', s(:test, nil, 'x')),
|
||||
s(:test, nil, 'a')
|
||||
)
|
||||
|
@ -93,8 +84,7 @@ describe Oga::CSS::Parser do
|
|||
|
||||
example 'parse the ~ axis followed by a pseudo class' do
|
||||
parse_css('a ~ x:root').should == s(
|
||||
:axis,
|
||||
'following',
|
||||
:following,
|
||||
s(:test, nil, 'a'),
|
||||
s(:pseudo, 'root', s(:test, nil, 'x'))
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue