mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-05 16:41:52 +00:00
LibWeb: Do not require visible nodes in the wrap editing algorithm
The spec doesn't say they should exist, so we should not `VERIFY_NOT_REACHED()` when they don't. Prevents a crash in the WPT `editing/event.html` tests.
This commit is contained in:
parent
c093c895da
commit
c0285f4a7e
Notes:
github-actions[bot]
2024-12-21 18:16:49 +00:00
Author: https://github.com/gmta
Commit: c0285f4a7e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2991
1 changed files with 5 additions and 5 deletions
|
@ -2638,23 +2638,23 @@ GC::Ptr<DOM::Node> wrap(
|
|||
// of node list are both inline nodes, and the last child of new parent is not a br, call createElement("br")
|
||||
// on the ownerDocument of new parent and append the result as the last child of new parent.
|
||||
if (!is_inline_node(*new_parent)) {
|
||||
auto last_visible_child = [&] -> GC::Ref<DOM::Node> {
|
||||
auto last_visible_child = [&] -> GC::Ptr<DOM::Node> {
|
||||
GC::Ptr<DOM::Node> child = new_parent->last_child();
|
||||
while (child) {
|
||||
if (is_visible_node(*child))
|
||||
return *child;
|
||||
child = child->previous_sibling();
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
return {};
|
||||
}();
|
||||
auto first_visible_member = [&] -> GC::Ref<DOM::Node> {
|
||||
auto first_visible_member = [&] -> GC::Ptr<DOM::Node> {
|
||||
for (auto& member : node_list) {
|
||||
if (is_visible_node(member))
|
||||
return member;
|
||||
}
|
||||
VERIFY_NOT_REACHED();
|
||||
return {};
|
||||
}();
|
||||
if (is_inline_node(last_visible_child) && is_inline_node(first_visible_member)
|
||||
if (last_visible_child && is_inline_node(*last_visible_child) && first_visible_member && is_inline_node(*first_visible_member)
|
||||
&& !is<HTML::HTMLBRElement>(new_parent->last_child())) {
|
||||
auto br_element = MUST(DOM::create_element(*new_parent->owner_document(), HTML::TagNames::br, Namespace::HTML));
|
||||
MUST(new_parent->append_child(br_element));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue