Parsing support for the :only-of-type pseudo.

This commit is contained in:
Yorick Peterse 2014-11-03 23:47:25 +01:00
parent 2cf058457d
commit 1b870406de
2 changed files with 20 additions and 0 deletions

View File

@ -541,6 +541,15 @@ end
return s(:and, on_pseudo_class_first_child, on_pseudo_class_last_child) return s(:and, on_pseudo_class_first_child, on_pseudo_class_last_child)
end 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 private
## ##

View File

@ -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