mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-24 02:09:28 +00:00
LibWeb: Make Node::is_text() return true for CDATASection nodes
CDATASection inherits from Text, and so it was incorrect for them to claim not to be Text nodes. This fixes at least two WPT subtests. :^) It also exposed a bug in the DOM Parsing and Serialization spec, where we're not told how to serialize CDATASection nodes. Spec bug: https://github.com/w3c/DOM-Parsing/issues/38
This commit is contained in:
committed by
Tim Ledbetter
parent
564dc0a434
commit
6ffc7ea36d
@@ -196,6 +196,14 @@ WebIDL::ExceptionOr<String> serialize_node_to_xml_string_impl(GC::Ref<DOM::Node
|
||||
return serialize_comment(static_cast<DOM::Comment const&>(*root), require_well_formed);
|
||||
}
|
||||
|
||||
// NOTE: CDATASection comes before Text since CDATASection is a subclass of Text.
|
||||
if (is<DOM::CDATASection>(*root)) {
|
||||
// Note: Serialization of CDATASection nodes is not mentioned in the specification, but treating CDATASection nodes as
|
||||
// text leads to incorrect serialization.
|
||||
// Spec bug: https://github.com/w3c/DOM-Parsing/issues/38
|
||||
return serialize_cdata_section(static_cast<DOM::CDATASection const&>(*root), require_well_formed);
|
||||
}
|
||||
|
||||
if (is<DOM::Text>(*root)) {
|
||||
// -> Text
|
||||
// Run the algorithm for XML serializing a Text node node.
|
||||
@@ -220,12 +228,6 @@ WebIDL::ExceptionOr<String> serialize_node_to_xml_string_impl(GC::Ref<DOM::Node
|
||||
return serialize_processing_instruction(static_cast<DOM::ProcessingInstruction const&>(*root), require_well_formed);
|
||||
}
|
||||
|
||||
if (is<DOM::CDATASection>(*root)) {
|
||||
// Note: Serialization of CDATASection nodes is not mentioned in the specification, but treating CDATASection nodes as
|
||||
// text leads to incorrect serialization.
|
||||
return serialize_cdata_section(static_cast<DOM::CDATASection const&>(*root), require_well_formed);
|
||||
}
|
||||
|
||||
if (is<DOM::Attr>(*root)) {
|
||||
// -> An Attr object
|
||||
// Return an empty string.
|
||||
|
||||
Reference in New Issue
Block a user