mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-28 07:18:51 +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:
parent
564dc0a434
commit
6ffc7ea36d
Notes:
github-actions[bot]
2024-11-19 19:25:35 +00:00
Author: https://github.com/awesomekling
Commit: 6ffc7ea36d
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2441
Reviewed-by: https://github.com/tcl3 ✅
5 changed files with 2545 additions and 7 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue