mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-17 23:12:22 +00:00
WebContent: Use outerHTML to copy a DOM node's HTML in the Inspector
We can use outerHTML now instead of cloning the node into a temporary container and invoking the container's innerHTML.
This commit is contained in:
parent
b5ebbe6159
commit
12b3332d3c
Notes:
sideshowbarker
2024-07-17 03:27:40 +09:00
Author: https://github.com/trflynn89
Commit: 12b3332d3c
Pull-request: https://github.com/SerenityOS/serenity/pull/23913
1 changed files with 11 additions and 4 deletions
|
@ -745,11 +745,18 @@ void ConnectionFromClient::get_dom_node_html(u64 page_id, i32 node_id)
|
|||
if (!dom_node)
|
||||
return;
|
||||
|
||||
// FIXME: Implement Element's outerHTML attribute.
|
||||
auto container = Web::DOM::create_element(dom_node->document(), Web::HTML::TagNames::div, Web::Namespace::HTML).release_value_but_fixme_should_propagate_errors();
|
||||
container->append_child(dom_node->clone_node(nullptr, true)).release_value_but_fixme_should_propagate_errors();
|
||||
String html;
|
||||
|
||||
if (dom_node->is_element()) {
|
||||
auto const& element = static_cast<Web::DOM::Element const&>(*dom_node);
|
||||
html = element.outer_html().release_value_but_fixme_should_propagate_errors();
|
||||
} else if (dom_node->is_text() || dom_node->is_comment()) {
|
||||
auto const& character_data = static_cast<Web::DOM::CharacterData const&>(*dom_node);
|
||||
html = character_data.data();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
auto html = container->inner_html().release_value_but_fixme_should_propagate_errors();
|
||||
async_did_get_dom_node_html(page_id, move(html));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue