Parsing support for the :first-child pseudo class.
This commit is contained in:
parent
020d979fba
commit
b4fec3cc8c
|
@ -488,6 +488,19 @@ end
|
||||||
return node
|
return node
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Generates the AST for the `:first-child` selector.
|
||||||
|
#
|
||||||
|
# @return [AST::Node]
|
||||||
|
#
|
||||||
|
def on_pseudo_class_first_child
|
||||||
|
return s(
|
||||||
|
:eq,
|
||||||
|
s(:call, 'count', s(:axis, 'preceding-sibling', s(:test, nil, '*'))),
|
||||||
|
s(:int, 0)
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Oga::CSS::Parser do
|
||||||
|
context ':first-child pseudo class' do
|
||||||
|
example 'parse the :first-child pseudo class' do
|
||||||
|
parse_css(':first-child').should == parse_xpath(
|
||||||
|
'descendant-or-self::*[count(preceding-sibling::*) = 0]'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue