LibWeb/XML: Do not create text nodes for empty text chunks

This corresponds to the empty text node between foo and bar in
`<foo/><bar/>`, which is not supposed to become a text node in HTML.
This commit is contained in:
Ali Mohammad Pur 2023-10-07 14:45:28 +03:30 committed by Andreas Kling
parent ae4e46a037
commit 830f1dbbfe

View file

@ -146,8 +146,10 @@ void XMLDocumentBuilder::text(StringView data)
auto string = DeprecatedString::empty();
if (!data.is_null())
string = data.to_deprecated_string();
auto node = m_document->create_text_node(MUST(String::from_deprecated_string(string)));
MUST(m_current_node->append_child(node));
if (!string.is_empty()) {
auto node = m_document->create_text_node(MUST(String::from_deprecated_string(string)));
MUST(m_current_node->append_child(node));
}
}
}