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
|
axis
|
||||||
# x > y
|
# x > y
|
||||||
: path_member T_CHILD path_member
|
: path_member T_CHILD path_member { s(:child, val[0], val[2]) }
|
||||||
{
|
|
||||||
s(:axis, 'child', val[0], val[2])
|
|
||||||
}
|
|
||||||
|
|
||||||
# x + y
|
# x + y
|
||||||
| path_member T_FOLLOWING path_member
|
| path_member T_FOLLOWING path_member { s(:following, val[0], val[2]) }
|
||||||
{
|
|
||||||
s(:axis, 'following', val[0], val[2])
|
|
||||||
}
|
|
||||||
|
|
||||||
# x ~ y
|
# x ~ y
|
||||||
| path_member T_FOLLOWING_DIRECT path_member
|
| 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
|
context 'axes' do
|
||||||
example 'parse the > axis' do
|
example 'parse the > axis' do
|
||||||
parse_css('x > y').should == s(
|
parse_css('x > y').should == s(
|
||||||
:axis,
|
:child,
|
||||||
'child',
|
|
||||||
s(:test, nil, 'x'),
|
s(:test, nil, 'x'),
|
||||||
s(:test, nil, 'y')
|
s(:test, nil, 'y')
|
||||||
)
|
)
|
||||||
|
@ -13,17 +12,15 @@ describe Oga::CSS::Parser do
|
||||||
|
|
||||||
example 'parse the > axis called on another > axis' do
|
example 'parse the > axis called on another > axis' do
|
||||||
parse_css('a > b > c').should == s(
|
parse_css('a > b > c').should == s(
|
||||||
:axis,
|
:child,
|
||||||
'child',
|
s(:child, s(:test, nil, 'a'), s(:test, nil, 'b')),
|
||||||
s(:axis, 'child', s(:test, nil, 'a'), s(:test, nil, 'b')),
|
|
||||||
s(:test, nil, 'c')
|
s(:test, nil, 'c')
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
example 'parse an > axis followed by an element with an ID' do
|
example 'parse an > axis followed by an element with an ID' do
|
||||||
parse_css('x > foo#bar').should == s(
|
parse_css('x > foo#bar').should == s(
|
||||||
:axis,
|
:child,
|
||||||
'child',
|
|
||||||
s(:test, nil, 'x'),
|
s(:test, nil, 'x'),
|
||||||
s(:id, 'bar', s(:test, nil, 'foo'))
|
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
|
example 'parse an > axis followed by an element with a class' do
|
||||||
parse_css('x > foo.bar').should == s(
|
parse_css('x > foo.bar').should == s(
|
||||||
:axis,
|
:child,
|
||||||
'child',
|
|
||||||
s(:test, nil, 'x'),
|
s(:test, nil, 'x'),
|
||||||
s(:class, 'bar', s(:test, nil, 'foo'))
|
s(:class, 'bar', s(:test, nil, 'foo'))
|
||||||
)
|
)
|
||||||
|
@ -40,8 +36,7 @@ describe Oga::CSS::Parser do
|
||||||
|
|
||||||
example 'parse the + axis' do
|
example 'parse the + axis' do
|
||||||
parse_css('x + y').should == s(
|
parse_css('x + y').should == s(
|
||||||
:axis,
|
:following_direct,
|
||||||
'following-direct',
|
|
||||||
s(:test, nil, 'x'),
|
s(:test, nil, 'x'),
|
||||||
s(:test, nil, 'y')
|
s(:test, nil, 'y')
|
||||||
)
|
)
|
||||||
|
@ -49,17 +44,15 @@ describe Oga::CSS::Parser do
|
||||||
|
|
||||||
example 'parse the + axis called on another + axis' do
|
example 'parse the + axis called on another + axis' do
|
||||||
parse_css('a + b + c').should == s(
|
parse_css('a + b + c').should == s(
|
||||||
:axis,
|
:following_direct,
|
||||||
'following-direct',
|
s(:following_direct, s(:test, nil, 'a'), s(:test, nil, 'b')),
|
||||||
s(:axis, 'following-direct', s(:test, nil, 'a'), s(:test, nil, 'b')),
|
|
||||||
s(:test, nil, 'c')
|
s(:test, nil, 'c')
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
example 'parse the ~ axis' do
|
example 'parse the ~ axis' do
|
||||||
parse_css('x ~ y').should == s(
|
parse_css('x ~ y').should == s(
|
||||||
:axis,
|
:following,
|
||||||
'following',
|
|
||||||
s(:test, nil, 'x'),
|
s(:test, nil, 'x'),
|
||||||
s(:test, nil, 'y')
|
s(:test, nil, 'y')
|
||||||
)
|
)
|
||||||
|
@ -68,24 +61,22 @@ describe Oga::CSS::Parser do
|
||||||
example 'parse the ~ axis followed by another node test' do
|
example 'parse the ~ axis followed by another node test' do
|
||||||
parse_css('x ~ y z').should == s(
|
parse_css('x ~ y z').should == s(
|
||||||
:path,
|
: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')
|
s(:test, nil, 'z')
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
example 'parse the ~ axis called on another ~ axis' do
|
example 'parse the ~ axis called on another ~ axis' do
|
||||||
parse_css('a ~ b ~ c').should == s(
|
parse_css('a ~ b ~ c').should == s(
|
||||||
:axis,
|
:following,
|
||||||
'following',
|
s(:following, s(:test, nil, 'a'), s(:test, nil, 'b')),
|
||||||
s(:axis, 'following', s(:test, nil, 'a'), s(:test, nil, 'b')),
|
|
||||||
s(:test, nil, 'c')
|
s(:test, nil, 'c')
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
example 'parse a pseudo class followed by the ~ axis' do
|
example 'parse a pseudo class followed by the ~ axis' do
|
||||||
parse_css('x:root ~ a').should == s(
|
parse_css('x:root ~ a').should == s(
|
||||||
:axis,
|
:following,
|
||||||
'following',
|
|
||||||
s(:pseudo, 'root', s(:test, nil, 'x')),
|
s(:pseudo, 'root', s(:test, nil, 'x')),
|
||||||
s(:test, nil, 'a')
|
s(:test, nil, 'a')
|
||||||
)
|
)
|
||||||
|
@ -93,8 +84,7 @@ describe Oga::CSS::Parser do
|
||||||
|
|
||||||
example 'parse the ~ axis followed by a pseudo class' do
|
example 'parse the ~ axis followed by a pseudo class' do
|
||||||
parse_css('a ~ x:root').should == s(
|
parse_css('a ~ x:root').should == s(
|
||||||
:axis,
|
:following,
|
||||||
'following',
|
|
||||||
s(:test, nil, 'a'),
|
s(:test, nil, 'a'),
|
||||||
s(:pseudo, 'root', s(:test, nil, 'x'))
|
s(:pseudo, 'root', s(:test, nil, 'x'))
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue