Use HTML5 style closing tags for void elements
This ensures that element tags such as <img> tags don't use a closing /> when documents are parsed as HTML documents. Fixes #170
This commit is contained in:
4 files changed
+57
-3
No files matched your search
@@ -136,7 +136,9 @@ module Oga
|
||||
end
|
||||
|
||||
if self_closing?(element)
|
||||
output << "<#{name}#{attrs} />"
|
||||
closing_tag = html_void_element?(element) ? '>' : ' />'
|
||||
|
||||
output << "<#{name}#{attrs}#{closing_tag}"
|
||||
else
|
||||
output << "<#{name}#{attrs}>"
|
||||
end
|
||||
@@ -214,6 +216,10 @@ module Oga
|
||||
element.children.empty?
|
||||
end
|
||||
end
|
||||
|
||||
def html_void_element?(element)
|
||||
@html_mode && HTML_VOID_ELEMENTS.allow?(element.name)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user