Merge pull request #39 from ttasanen/fix_uc_void_tags

Ignore casing when testing for html void elements
This commit is contained in:
Yorick Peterse 2014-09-14 14:34:16 +02:00
commit 96b6ef320b
3 changed files with 23 additions and 1 deletions

View File

@ -347,7 +347,7 @@ module Oga
# Called on the closing `>` of the open tag of an element.
#
def on_element_open_end
if html? and HTML_VOID_ELEMENTS.include?(current_element)
if html? and HTML_VOID_ELEMENTS.include?(current_element.downcase)
add_token(:T_ELEM_END)
@elements.pop
end

View File

@ -10,6 +10,14 @@ describe Oga::XML::Lexer do
]
end
example 'lex a upper case void element' do
lex('<BR>', :html => true).should == [
[:T_ELEM_START, nil, 1],
[:T_ELEM_NAME, "BR", 1],
[:T_ELEM_END, nil, 1]
]
end
example 'lex text after a void element' do
lex('<link>foo', :html => true).should == [
[:T_ELEM_START, nil, 1],

View File

@ -29,6 +29,20 @@ describe Oga::XML::Parser do
end
end
context 'void elements with different casing' do
before :all do
@node_uc = parse_html('<BR>').children[0]
end
example 'parse void elements with different casing' do
@node_uc.is_a?(Oga::XML::Element).should == true
end
example 'set the name of the void element to match casing' do
@node_uc.name.should == 'BR'
end
end
context 'void elements with attributes' do
before :all do
@node = parse('<link href="foo">', :html => true).children[0]