mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01: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:
parent
7c7fec5e00
commit
556acd82ee
|
|
@ -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))
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
strikeThrough active?: false
|
||||
strikeThrough active?: true
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user