Parsing support for the :only-of-type pseudo.
This commit is contained in:
parent
2cf058457d
commit
1b870406de
|
@ -541,6 +541,15 @@ end
|
|||
return s(:and, on_pseudo_class_first_child, on_pseudo_class_last_child)
|
||||
end
|
||||
|
||||
##
|
||||
# Generates the AST for the `:only-of-type` selector.
|
||||
#
|
||||
# @return [AST::Node]
|
||||
#
|
||||
def on_pseudo_class_only_of_type
|
||||
return s(:eq, s(:call, 'last'), s(:int, 1))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
##
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Oga::CSS::Parser do
|
||||
context ':only-of-type pseudo class' do
|
||||
example 'parse the :only-of-type pseudo class' do
|
||||
parse_css(':only-of-type').should == parse_xpath(
|
||||
'descendant-or-self::*[last() = 1]'
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue