Parsing support for the :last-of-type pseudo.
This commit is contained in:
parent
10632eafd4
commit
759bb71d17
|
@ -515,12 +515,23 @@ end
|
||||||
end
|
end
|
||||||
|
|
||||||
##
|
##
|
||||||
|
# Generates the AST for the `:first-of-type` selector.
|
||||||
|
#
|
||||||
# @return [AST::Node]
|
# @return [AST::Node]
|
||||||
#
|
#
|
||||||
def on_pseudo_class_first_of_type
|
def on_pseudo_class_first_of_type
|
||||||
return s(:eq, s(:call, 'position'), s(:int, 1))
|
return s(:eq, s(:call, 'position'), s(:int, 1))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##
|
||||||
|
# Generates the AST for the `:last-of-type` selector.
|
||||||
|
#
|
||||||
|
# @return [AST::Node]
|
||||||
|
#
|
||||||
|
def on_pseudo_class_last_of_type
|
||||||
|
return s(:eq, s(:call, 'position'), s(:call, 'last'))
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe Oga::CSS::Parser do
|
||||||
|
context ':last-of-type pseudo class' do
|
||||||
|
example 'parse the :last-of-type pseudo class' do
|
||||||
|
parse_css(':last-of-type').should == parse_xpath(
|
||||||
|
'descendant-or-self::*[position() = last()]'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue