diff --git a/Meta/gn/secondary/Userland/Libraries/LibWeb/DOMParsing/BUILD.gn b/Meta/gn/secondary/Userland/Libraries/LibWeb/DOMParsing/BUILD.gn index cb5694ef684..a6f354cf21f 100644 --- a/Meta/gn/secondary/Userland/Libraries/LibWeb/DOMParsing/BUILD.gn +++ b/Meta/gn/secondary/Userland/Libraries/LibWeb/DOMParsing/BUILD.gn @@ -1,8 +1,5 @@ source_set("DOMParsing") { configs += [ "//Userland/Libraries/LibWeb:configs" ] deps = [ "//Userland/Libraries/LibWeb:all_generated" ] - sources = [ - "InnerHTML.cpp", - "XMLSerializer.cpp", - ] + sources = [ "XMLSerializer.cpp" ] } diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index e78f63d6159..1ec25502d6d 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -193,7 +193,6 @@ set(SOURCES DOM/Text.cpp DOM/TreeWalker.cpp DOM/XMLDocument.cpp - DOMParsing/InnerHTML.cpp DOMParsing/XMLSerializer.cpp DOMURL/DOMURL.cpp DOMURL/URLSearchParams.cpp diff --git a/Userland/Libraries/LibWeb/DOM/Element.cpp b/Userland/Libraries/LibWeb/DOM/Element.cpp index aaa876fd6ea..9551c05f61b 100644 --- a/Userland/Libraries/LibWeb/DOM/Element.cpp +++ b/Userland/Libraries/LibWeb/DOM/Element.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -49,6 +48,7 @@ #include #include #include +#include #include #include #include @@ -754,13 +754,38 @@ WebIDL::ExceptionOr Element::closest(StringView selectors) return nullptr; } -WebIDL::ExceptionOr Element::set_inner_html(StringView markup) +// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-element-innerhtml +WebIDL::ExceptionOr Element::set_inner_html(StringView value) { - TRY(DOMParsing::inner_html_setter(*this, markup)); + // FIXME: 1. Let compliantString be the result of invoking the Get Trusted Type compliant string algorithm with TrustedHTML, this's relevant global object, the given value, "Element innerHTML", and "script". + + // 2. Let context be this. + DOM::Node* context = this; + + // 3. Let fragment be the result of invoking the fragment parsing algorithm steps with context and compliantString. FIXME: Use compliantString. + auto fragment = TRY(verify_cast(*context).parse_fragment(value)); + + // 4. If context is a template element, then set context to the template element's template contents (a DocumentFragment). + if (is(*context)) + context = verify_cast(*context).content(); + + // 5. Replace all with fragment within context. + context->replace_all(fragment); + + // NOTE: We don't invalidate style & layout for