1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-08 05:27:14 +09:00

LibWeb/Editing: Handle no active range in queryCommandState

Fixes a crash when this is invoked if no range is active for the
document.
This commit is contained in:
Shannon Booth 2025-05-25 12:26:22 +12:00 committed by Jelle Raaijmakers
parent 7c7fec5e00
commit 556acd82ee
Notes: github-actions[bot] 2025-05-26 21:37:43 +00:00
3 changed files with 5 additions and 1 deletions

View file

@ -329,6 +329,9 @@ WebIDL::ExceptionOr<bool> Document::query_command_state(FlyString const& command
if (inline_values.is_empty())
return false;
auto range = Editing::active_range(*this);
if (!range)
return false;
Vector<GC::Ref<Node>> formattable_nodes;
Editing::for_each_node_effectively_contained_in_range(range, [&](GC::Ref<Node> descendant) {
if (Editing::is_formattable_node(descendant))

View file

@ -1 +1,2 @@
strikeThrough active?: false
strikeThrough active?: true

View file

@ -9,7 +9,7 @@
const range = document.createRange();
const selection = window.getSelection();
// println(`strikeThrough active?: ${document.queryCommandState("strikeThrough")}`);
println(`strikeThrough active?: ${document.queryCommandState("strikeThrough")}`);
range.selectNodeContents(target);
selection.removeAllRanges();
selection.addRange(range);