Reverted AST changes for first-of-type

Functions can't be used in combination with axes, so I'll just need to fix the
position() function to work properly.
This commit is contained in:
Yorick Peterse 2014-11-14 23:51:46 +01:00
parent 2d6a2be2e8
commit 6daa3e7a00
2 changed files with 3 additions and 7 deletions

View File

@ -515,11 +515,7 @@ end
# @return [AST::Node] # @return [AST::Node]
# #
def on_pseudo_class_first_of_type def on_pseudo_class_first_of_type
return s( return s(:eq, s(:call, 'position'), s(:int, 1))
:eq,
s(:call, 'count', s(:axis, 'preceding-sibling', s(:call, 'name'))),
s(:int, 0)
)
end end
## ##

View File

@ -4,13 +4,13 @@ describe Oga::CSS::Parser do
context ':first-of-type pseudo class' do context ':first-of-type pseudo class' do
example 'parse the :first-of-type pseudo class' do example 'parse the :first-of-type pseudo class' do
parse_css(':first-of-type').should == parse_xpath( parse_css(':first-of-type').should == parse_xpath(
'descendant::*[count(preceding-sibling::name()) = 0]' 'descendant::*[position() = 1]'
) )
end end
example 'parse the a:first-of-type pseudo class' do example 'parse the a:first-of-type pseudo class' do
parse_css('a:first-of-type').should == parse_xpath( parse_css('a:first-of-type').should == parse_xpath(
'descendant::a[count(preceding-sibling::name()) = 0]' 'descendant::a[position() = 1]'
) )
end end
end end