|
@@ -1173,15 +1173,17 @@ void Node::string_replace_all(String const& string)
|
|
|
}
|
|
|
|
|
|
// https://w3c.github.io/DOM-Parsing/#dfn-fragment-serializing-algorithm
|
|
|
-String Node::serialize_fragment(/* FIXME: Requires well-formed flag */) const
|
|
|
+WebIDL::ExceptionOr<String> Node::serialize_fragment(DOMParsing::RequireWellFormed require_well_formed) const
|
|
|
{
|
|
|
- // FIXME: 1. Let context document be the value of node's node document.
|
|
|
+ // 1. Let context document be the value of node's node document.
|
|
|
+ auto const& context_document = document();
|
|
|
|
|
|
- // FIXME: 2. If context document is an HTML document, return an HTML serialization of node.
|
|
|
- // (We currently always do this)
|
|
|
- return HTML::HTMLParser::serialize_html_fragment(*this);
|
|
|
+ // 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);
|
|
|
|
|
|
- // FIXME: 3. Otherwise, context document is an XML document; return an XML serialization of node passing the flag require well-formed.
|
|
|
+ // 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);
|
|
|
}
|
|
|
|
|
|
// https://dom.spec.whatwg.org/#dom-node-issamenode
|