From ed0cd7826e2a33c6f1eef3679de8b7370eb8b542 Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Tue, 7 Oct 2014 23:05:34 +0200 Subject: [PATCH] Fixed precedence of ID/class CSS selectors --- lib/oga/css/parser.y | 2 +- spec/oga/css/parser/axes_spec.rb | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/oga/css/parser.y b/lib/oga/css/parser.y index 73b36fe..2eb99a2 100644 --- a/lib/oga/css/parser.y +++ b/lib/oga/css/parser.y @@ -11,7 +11,7 @@ token T_NTH T_INT T_STRING T_ODD T_EVEN T_DOT T_HASH options no_result_var prechigh - left T_COLON + left T_COLON T_HASH T_DOT left T_CHILD T_FOLLOWING T_FOLLOWING_DIRECT left T_DOT T_HASH preclow diff --git a/spec/oga/css/parser/axes_spec.rb b/spec/oga/css/parser/axes_spec.rb index 22022a8..665f4c8 100644 --- a/spec/oga/css/parser/axes_spec.rb +++ b/spec/oga/css/parser/axes_spec.rb @@ -20,6 +20,24 @@ describe Oga::CSS::Parser do ) end + example 'parse an > axis followed by an element with an ID' do + parse_css('x > foo#bar').should == s( + :axis, + 'child', + s(:test, nil, 'x'), + s(:id, 'bar', s(:test, nil, 'foo')) + ) + end + + example 'parse an > axis followed by an element with a class' do + parse_css('x > foo.bar').should == s( + :axis, + 'child', + s(:test, nil, 'x'), + s(:class, 'bar', s(:test, nil, 'foo')) + ) + end + example 'parse the + axis' do parse_css('x + y').should == s( :axis,