Use Whitelist for HTML_VOID_ELEMENTS
This commit is contained in:
parent
596a9b18d6
commit
bcc101b819
|
@ -352,7 +352,7 @@ module Oga
|
||||||
root = root_node
|
root = root_node
|
||||||
|
|
||||||
if root.is_a?(Document) and root.html? \
|
if root.is_a?(Document) and root.html? \
|
||||||
and !HTML_VOID_ELEMENTS.include?(name)
|
and !HTML_VOID_ELEMENTS.allow?(name)
|
||||||
self_closing = false
|
self_closing = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -4,25 +4,11 @@ module Oga
|
||||||
# Names of the HTML void elements that should be handled when HTML lexing
|
# Names of the HTML void elements that should be handled when HTML lexing
|
||||||
# is enabled.
|
# is enabled.
|
||||||
#
|
#
|
||||||
# @return [Oga::NodeNameSet]
|
# @return [Oga::Whitelist]
|
||||||
#
|
#
|
||||||
HTML_VOID_ELEMENTS = NodeNameSet.new([
|
HTML_VOID_ELEMENTS = Whitelist.new(%w{
|
||||||
'area',
|
area base br col command embed hr img input keygen link meta param source
|
||||||
'base',
|
track wbr
|
||||||
'br',
|
})
|
||||||
'col',
|
|
||||||
'command',
|
|
||||||
'embed',
|
|
||||||
'hr',
|
|
||||||
'img',
|
|
||||||
'input',
|
|
||||||
'keygen',
|
|
||||||
'link',
|
|
||||||
'meta',
|
|
||||||
'param',
|
|
||||||
'source',
|
|
||||||
'track',
|
|
||||||
'wbr'
|
|
||||||
])
|
|
||||||
end # XML
|
end # XML
|
||||||
end # Oga
|
end # Oga
|
||||||
|
|
|
@ -466,8 +466,8 @@ module Oga
|
||||||
|
|
||||||
# Only downcase the name if we can't find an all lower/upper version of
|
# Only downcase the name if we can't find an all lower/upper version of
|
||||||
# the element name. This can save us a *lot* of String allocations.
|
# the element name. This can save us a *lot* of String allocations.
|
||||||
if HTML_VOID_ELEMENTS.include?(current_element) \
|
if HTML_VOID_ELEMENTS.allow?(current_element) \
|
||||||
or HTML_VOID_ELEMENTS.include?(current_element.downcase)
|
or HTML_VOID_ELEMENTS.allow?(current_element.downcase)
|
||||||
add_token(:T_ELEM_END)
|
add_token(:T_ELEM_END)
|
||||||
@elements.pop
|
@elements.pop
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue