From d424dc1b32e44977905cdc67f40639836b113918 Mon Sep 17 00:00:00 2001 From: Jelle Raaijmakers Date: Wed, 7 May 2025 14:26:48 +0200 Subject: [PATCH] LibWeb: Assign new wrapped node list to container for insertParagraph Forgot to implement this part of the spec. --- Libraries/LibWeb/Editing/Commands.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Libraries/LibWeb/Editing/Commands.cpp b/Libraries/LibWeb/Editing/Commands.cpp index 6a731d9c86c..c6d9ed6a4e3 100644 --- a/Libraries/LibWeb/Editing/Commands.cpp +++ b/Libraries/LibWeb/Editing/Commands.cpp @@ -1546,10 +1546,14 @@ bool command_insert_paragraph_action(DOM::Document& document, String const&) // 7. Wrap node list, with sibling criteria returning false and new parent instructions returning the result of // calling createElement(tag) on the context object. Set container to the result. - wrap( + // AD-HOC: wrap() does not always return something, but the rest of this algorithm expects it to be a valid + // node. Therefore, we only change the container if we successfully wrapped the node list. + auto new_container = wrap( node_list, [](auto) { return false; }, [&] { return MUST(DOM::create_element(document, tag, Namespace::HTML)); }); + if (new_container) + container = new_container; } // 12. If container's local name is "address", "listing", or "pre":