diff --git a/lib/oga/css/parser.y b/lib/oga/css/parser.y index e232ee2..09e5b56 100644 --- a/lib/oga/css/parser.y +++ b/lib/oga/css/parser.y @@ -528,11 +528,7 @@ end # @return [AST::Node] # def on_pseudo_class_last_of_type - return s( - :eq, - s(:call, 'count', s(:axis, 'following-sibling', s(:call, 'name'))), - s(:int, 0) - ) + return s(:eq, s(:call, 'position'), s(:call, 'last')) end ## diff --git a/spec/oga/css/parser/pseudo_classes/last_of_type_spec.rb b/spec/oga/css/parser/pseudo_classes/last_of_type_spec.rb index 39b4b91..64f1d78 100644 --- a/spec/oga/css/parser/pseudo_classes/last_of_type_spec.rb +++ b/spec/oga/css/parser/pseudo_classes/last_of_type_spec.rb @@ -4,7 +4,7 @@ describe Oga::CSS::Parser do context ':last-of-type pseudo class' do example 'parse the :last-of-type pseudo class' do parse_css(':last-of-type').should == parse_xpath( - 'descendant::*[count(following-sibling::name()) = 0]' + 'descendant::*[position() = last()]' ) end end