mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-05 15:49:11 +00:00
LibWeb: Make the innerHTML setter spec compliant
This adds innerHTML to ShadowRoot in the process.
This commit is contained in:
parent
f62477c093
commit
8e0f3436a2
Notes:
sideshowbarker
2024-07-18 03:58:55 +09:00
Author: https://github.com/Lubrsi
Commit: 8e0f3436a2
Pull-request: https://github.com/SerenityOS/serenity/pull/10025
8 changed files with 109 additions and 9 deletions
33
Userland/Libraries/LibWeb/DOMParsing/Algorithms.h
Normal file
33
Userland/Libraries/LibWeb/DOMParsing/Algorithms.h
Normal file
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Luke Wilde <lukew@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibWeb/DOM/DocumentFragment.h>
|
||||
#include <LibWeb/DOM/ExceptionOr.h>
|
||||
#include <LibWeb/HTML/Parser/HTMLDocumentParser.h>
|
||||
|
||||
namespace Web::DOMParsing {
|
||||
|
||||
// https://w3c.github.io/DOM-Parsing/#dfn-fragment-parsing-algorithm
|
||||
static DOM::ExceptionOr<NonnullRefPtr<DOM::DocumentFragment>> parse_fragment(String const& markup, DOM::Element& context_element)
|
||||
{
|
||||
// FIXME: Handle XML documents.
|
||||
|
||||
auto new_children = HTML::HTMLDocumentParser::parse_html_fragment(context_element, markup);
|
||||
auto fragment = make_ref_counted<DOM::DocumentFragment>(context_element.document());
|
||||
|
||||
for (auto& child : new_children) {
|
||||
// I don't know if this can throw here, but let's be safe.
|
||||
auto result = fragment->append_child(child);
|
||||
if (result.is_exception())
|
||||
return result.exception();
|
||||
}
|
||||
|
||||
return fragment;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue