From 2d6a2be2e8c23fc1a31c8044ba22d1ec1f22685e Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Fri, 14 Nov 2014 23:49:49 +0100 Subject: [PATCH] Revert "Fixed XPath AST for :last-of-type" Axes can't be used in combination with functions. This reverts commit b0b572a5846a884bcd267f8b0dc638dd511e9f52. --- lib/oga/css/parser.y | 6 +----- spec/oga/css/parser/pseudo_classes/last_of_type_spec.rb | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) 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