diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index d2de1f7032..82001301ae 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -1333,7 +1333,7 @@ WebIDL::ExceptionOr Node::serialize_fragment(DOMParsing::Requi // 2. If context document is an HTML document, return an HTML serialization of node. if (context_document.is_html_document()) - return HTML::HTMLParser::serialize_html_fragment(*this); + return HTML::HTMLParser::serialize_html_fragment(*this).to_deprecated_string(); // 3. Otherwise, context document is an XML document; return an XML serialization of node passing the flag require well-formed. return DOMParsing::serialize_node_to_xml_string(*this, require_well_formed); diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp index 2cb90e409b..178077404d 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp @@ -3849,19 +3849,19 @@ JS::NonnullGCPtr HTMLParser::create(DOM::Document& document, StringV } // https://html.spec.whatwg.org/multipage/parsing.html#html-fragment-serialisation-algorithm -DeprecatedString HTMLParser::serialize_html_fragment(DOM::Node const& node) +String HTMLParser::serialize_html_fragment(DOM::Node const& node) { // The algorithm takes as input a DOM Element, Document, or DocumentFragment referred to as the node. VERIFY(node.is_element() || node.is_document() || node.is_document_fragment()); JS::NonnullGCPtr actual_node = node; if (is(node)) { - auto& element = verify_cast(node); + auto const& element = verify_cast(node); // 1. If the node serializes as void, then return the empty string. // (NOTE: serializes as void is defined only on elements in the spec) if (element.serializes_as_void()) - return DeprecatedString::empty(); + return String {}; // 3. If the node is a template element, then let the node instead be the template element's template contents (a DocumentFragment node). // (NOTE: This is out of order of the spec to avoid another dynamic cast. The second step just creates a string builder, so it shouldn't matter) @@ -3874,7 +3874,7 @@ DeprecatedString HTMLParser::serialize_html_fragment(DOM::Node const& node) Yes, }; - auto escape_string = [](StringView string, AttributeMode attribute_mode) -> DeprecatedString { + auto escape_string = [](StringView string, AttributeMode attribute_mode) -> String { // https://html.spec.whatwg.org/multipage/parsing.html#escapingString StringBuilder builder; for (auto code_point : Utf8View { string }) { @@ -3895,7 +3895,7 @@ DeprecatedString HTMLParser::serialize_html_fragment(DOM::Node const& node) else builder.append_code_point(code_point); } - return builder.to_deprecated_string(); + return MUST(builder.to_string()); }; // 2. Let s be a string, and initialize it to the empty string. @@ -4048,7 +4048,7 @@ DeprecatedString HTMLParser::serialize_html_fragment(DOM::Node const& node) }); // 5. Return s. - return builder.to_deprecated_string(); + return MUST(builder.to_string()); } // https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#current-dimension-value diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.h b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.h index b0229a9e30..50e1ff6883 100644 --- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.h +++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.h @@ -58,7 +58,7 @@ public: DOM::Document& document(); static Vector> parse_html_fragment(DOM::Element& context_element, StringView); - static DeprecatedString serialize_html_fragment(DOM::Node const& node); + static String serialize_html_fragment(DOM::Node const& node); enum class InsertionMode { #define __ENUMERATE_INSERTION_MODE(mode) mode,