Merge pull request #39 from ttasanen/fix_uc_void_tags
Ignore casing when testing for html void elements
This commit is contained in:
commit
96b6ef320b
|
@ -347,7 +347,7 @@ module Oga
|
||||||
# Called on the closing `>` of the open tag of an element.
|
# Called on the closing `>` of the open tag of an element.
|
||||||
#
|
#
|
||||||
def on_element_open_end
|
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)
|
add_token(:T_ELEM_END)
|
||||||
@elements.pop
|
@elements.pop
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,6 +10,14 @@ describe Oga::XML::Lexer do
|
||||||
]
|
]
|
||||||
end
|
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
|
example 'lex text after a void element' do
|
||||||
lex('<link>foo', :html => true).should == [
|
lex('<link>foo', :html => true).should == [
|
||||||
[:T_ELEM_START, nil, 1],
|
[:T_ELEM_START, nil, 1],
|
||||||
|
|
|
@ -29,6 +29,20 @@ describe Oga::XML::Parser do
|
||||||
end
|
end
|
||||||
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
|
context 'void elements with attributes' do
|
||||||
before :all do
|
before :all do
|
||||||
@node = parse('<link href="foo">', :html => true).children[0]
|
@node = parse('<link href="foo">', :html => true).children[0]
|
||||||
|
|
Loading…
Reference in New Issue