LibWeb: Implement XMLFragmentParser

Implement XMLFragmentParser based on the specification:
https://html.spec.whatwg.org/multipage/xhtml.html

Fixes one WPT in:
domparsing/insert_adjacent_html-xhtml.xhtml
This commit is contained in:
mikiubo 2025-09-11 00:27:13 +02:00 committed by Sam Atkins
parent 0b715b20a2
commit 5b2a71a712
Notes: github-actions[bot] 2025-10-23 10:08:05 +00:00
7 changed files with 267 additions and 2 deletions

View file

@ -92,6 +92,7 @@
#include <LibWeb/WebIDL/AbstractOperations.h>
#include <LibWeb/WebIDL/DOMException.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
#include <LibWeb/XML/XMLFragmentParser.h>
namespace Web::DOM {
@ -2054,9 +2055,9 @@ WebIDL::ExceptionOr<GC::Ref<DOM::DocumentFragment>> Element::parse_fragment(Stri
// 1. Let algorithm be the HTML fragment parsing algorithm.
auto algorithm = HTML::HTMLParser::parse_html_fragment;
// FIXME: 2. If context's node document is an XML document, then set algorithm to the XML fragment parsing algorithm.
// 2. If context's node document is an XML document, then set algorithm to the XML fragment parsing algorithm.
if (document().is_xml_document()) {
dbgln("FIXME: Handle fragment parsing of XML documents");
algorithm = XMLFragmentParser::parse_xml_fragment;
}
// 3. Let newChildren be the result of invoking algorithm given context and markup.