Allow "th" to occur in thead, tbody, and tfoot
Fixes https://gitlab.com/yorickpeterse/oga/issues/190
This commit is contained in:
parent
6c10f41446
commit
8ac0055e42
|
@ -58,7 +58,11 @@ module Oga
|
|||
|
||||
HTML_SCRIPT_ELEMENTS = Whitelist.new(%w{script template})
|
||||
|
||||
HTML_TABLE_ROW_ELEMENTS = Whitelist.new(%w{tr}) + HTML_SCRIPT_ELEMENTS
|
||||
# The elements that may occur in a thead, tbody, or tfoot.
|
||||
#
|
||||
# Technically "th" is not allowed per the HTML5 spec, but it's so commonly
|
||||
# used in these elements that we allow it anyway.
|
||||
HTML_TABLE_ROW_ELEMENTS = Whitelist.new(%w{tr th}) + HTML_SCRIPT_ELEMENTS
|
||||
|
||||
# Elements that should be closed automatically before a new opening tag is
|
||||
# processed.
|
||||
|
|
|
@ -53,5 +53,15 @@ describe Oga::XML::Lexer do
|
|||
[:T_ELEM_END, nil, 1]
|
||||
])
|
||||
end
|
||||
|
||||
it 'lexes a <tbody> element containing a <th> element' do
|
||||
expect(lex_html('<tbody><th>foo</th></tbody>')).to eq([
|
||||
[:T_ELEM_NAME, 'tbody', 1],
|
||||
[:T_ELEM_NAME, 'th', 1],
|
||||
[:T_TEXT, 'foo', 1],
|
||||
[:T_ELEM_END, nil, 1],
|
||||
[:T_ELEM_END, nil, 1]
|
||||
])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -53,5 +53,15 @@ describe Oga::XML::Lexer do
|
|||
[:T_ELEM_END, nil, 1]
|
||||
])
|
||||
end
|
||||
|
||||
it 'lexes a <tfoot> element containing a <th> element' do
|
||||
expect(lex_html('<tfoot><th>foo</th></tfoot>')).to eq([
|
||||
[:T_ELEM_NAME, 'tfoot', 1],
|
||||
[:T_ELEM_NAME, 'th', 1],
|
||||
[:T_TEXT, 'foo', 1],
|
||||
[:T_ELEM_END, nil, 1],
|
||||
[:T_ELEM_END, nil, 1]
|
||||
])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -53,5 +53,15 @@ describe Oga::XML::Lexer do
|
|||
[:T_ELEM_END, nil, 1]
|
||||
])
|
||||
end
|
||||
|
||||
it 'lexes a <thead> element containing a <th> element' do
|
||||
expect(lex_html('<thead><th>foo</th></thead>')).to eq([
|
||||
[:T_ELEM_NAME, 'thead', 1],
|
||||
[:T_ELEM_NAME, 'th', 1],
|
||||
[:T_TEXT, 'foo', 1],
|
||||
[:T_ELEM_END, nil, 1],
|
||||
[:T_ELEM_END, nil, 1]
|
||||
])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue