diff --git a/lib/oga/css/parser.y b/lib/oga/css/parser.y index 8f6dbd9..4aaef24 100644 --- a/lib/oga/css/parser.y +++ b/lib/oga/css/parser.y @@ -514,6 +514,13 @@ end ) end + ## + # @return [AST::Node] + # + def on_pseudo_class_first_of_type + return s(:eq, s(:call, 'position'), s(:int, 1)) + end + private ## diff --git a/spec/oga/css/parser/pseudo_classes/first_of_type_spec.rb b/spec/oga/css/parser/pseudo_classes/first_of_type_spec.rb new file mode 100644 index 0000000..4356bb7 --- /dev/null +++ b/spec/oga/css/parser/pseudo_classes/first_of_type_spec.rb @@ -0,0 +1,11 @@ +require 'spec_helper' + +describe Oga::CSS::Parser do + context ':first-of-type pseudo class' do + example 'parse the :first-of-type pseudo class' do + parse_css(':first-of-type').should == parse_xpath( + 'descendant-or-self::*[position() = 1]' + ) + end + end +end