Parsing support for the :only-child pseudo.
This commit is contained in:
parent
759bb71d17
commit
2cf058457d
|
|
@ -532,6 +532,15 @@ end
|
||||||
return s(:eq, s(:call, 'position'), s(:call, 'last'))
|
return s(:eq, s(:call, 'position'), s(:call, 'last'))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Generates the AST for the `:only-child` selector.
|
||||||
|
#
|
||||||
|
# @return [AST::Node]
|
||||||
|
#
|
||||||
|
def on_pseudo_class_only_child
|
||||||
|
return s(:and, on_pseudo_class_first_child, on_pseudo_class_last_child)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Oga::CSS::Parser do
|
||||||
|
context ':only-child pseudo class' do
|
||||||
|
example 'parse the :only-child pseudo class' do
|
||||||
|
parse_css(':only-child').should == parse_xpath(
|
||||||
|
'descendant-or-self::*[count(preceding-sibling::*) = 0 ' \
|
||||||
|
'and count(following-sibling::*) = 0]'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Reference in New Issue