diff --git a/lib/oga/xml/element.rb b/lib/oga/xml/element.rb index 79da3d7..106fa08 100644 --- a/lib/oga/xml/element.rb +++ b/lib/oga/xml/element.rb @@ -352,7 +352,7 @@ module Oga root = root_node if root.is_a?(Document) and root.html? \ - and !HTML_VOID_ELEMENTS.include?(name) + and !HTML_VOID_ELEMENTS.allow?(name) self_closing = false end diff --git a/lib/oga/xml/html_void_elements.rb b/lib/oga/xml/html_void_elements.rb index c0ee4d1..348f64e 100644 --- a/lib/oga/xml/html_void_elements.rb +++ b/lib/oga/xml/html_void_elements.rb @@ -4,25 +4,11 @@ module Oga # Names of the HTML void elements that should be handled when HTML lexing # is enabled. # - # @return [Oga::NodeNameSet] + # @return [Oga::Whitelist] # - HTML_VOID_ELEMENTS = NodeNameSet.new([ - 'area', - 'base', - 'br', - 'col', - 'command', - 'embed', - 'hr', - 'img', - 'input', - 'keygen', - 'link', - 'meta', - 'param', - 'source', - 'track', - 'wbr' - ]) + HTML_VOID_ELEMENTS = Whitelist.new(%w{ + area base br col command embed hr img input keygen link meta param source + track wbr + }) end # XML end # Oga diff --git a/lib/oga/xml/lexer.rb b/lib/oga/xml/lexer.rb index 4c38c50..756331b 100644 --- a/lib/oga/xml/lexer.rb +++ b/lib/oga/xml/lexer.rb @@ -466,8 +466,8 @@ module Oga # 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. - if HTML_VOID_ELEMENTS.include?(current_element) \ - or HTML_VOID_ELEMENTS.include?(current_element.downcase) + if HTML_VOID_ELEMENTS.allow?(current_element) \ + or HTML_VOID_ELEMENTS.allow?(current_element.downcase) add_token(:T_ELEM_END) @elements.pop end