mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:37:43 +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
8 changed files with 109 additions and 9 deletions
|
@ -17,6 +17,7 @@
|
|||
#include <LibWeb/DOM/HTMLCollection.h>
|
||||
#include <LibWeb/DOM/ShadowRoot.h>
|
||||
#include <LibWeb/DOM/Text.h>
|
||||
#include <LibWeb/DOMParsing/InnerHTML.h>
|
||||
#include <LibWeb/HTML/EventLoop/EventLoop.h>
|
||||
#include <LibWeb/HTML/Parser/HTMLDocumentParser.h>
|
||||
#include <LibWeb/Layout/BlockBox.h>
|
||||
|
@ -244,16 +245,15 @@ NonnullRefPtr<CSS::StyleProperties> Element::computed_style()
|
|||
return properties;
|
||||
}
|
||||
|
||||
void Element::set_inner_html(StringView markup)
|
||||
ExceptionOr<void> Element::set_inner_html(String const& markup)
|
||||
{
|
||||
auto new_children = HTML::HTMLDocumentParser::parse_html_fragment(*this, markup);
|
||||
remove_all_children();
|
||||
while (!new_children.is_empty()) {
|
||||
append_child(new_children.take_first());
|
||||
}
|
||||
auto result = DOMParsing::InnerHTML::inner_html_setter(*this, markup);
|
||||
if (result.is_exception())
|
||||
return result.exception();
|
||||
|
||||
set_needs_style_update(true);
|
||||
document().invalidate_layout();
|
||||
return {};
|
||||
}
|
||||
|
||||
// https://w3c.github.io/DOM-Parsing/#dom-innerhtml-innerhtml
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue