Parsing support for the :empty pseudo.

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

View File

@ -550,6 +550,15 @@ end
return s(:eq, s(:call, 'last'), s(:int, 1)) return s(:eq, s(:call, 'last'), s(:int, 1))
end end
##
# Generates the AST for the `:empty` selector.
#
# @return [AST::Node]
#
def on_pseudo_class_empty
return s(:call, 'not', s(:axis, 'child', s(:type_test, 'node')))
end
private private
## ##

View File

@ -0,0 +1,11 @@
require 'spec_helper'
describe Oga::CSS::Parser do
context ':empty pseudo class' do
example 'parse the :empty pseudo class' do
parse_css(':empty').should == parse_xpath(
'descendant-or-self::*[not(node())]'
)
end
end
end