diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 7a68d4c434..001996a3ee 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -2366,11 +2366,8 @@ void HTMLInputElement::selection_was_changed(size_t selection_start, size_t sele { document().set_cursor_position(DOM::Position::create(realm(), *m_text_node, selection_end)); - auto selection = document().get_selection(); - if (!selection || selection->range_count() == 0) - return; - - MUST(selection->set_base_and_extent(*m_text_node, selection_start, *m_text_node, selection_end)); + if (auto selection = document().get_selection()) + MUST(selection->set_base_and_extent(*m_text_node, selection_start, *m_text_node, selection_end)); } } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp index c2a3b05e40..1d63945521 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTextAreaElement.cpp @@ -464,11 +464,8 @@ void HTMLTextAreaElement::selection_was_changed(size_t selection_start, size_t s { document().set_cursor_position(DOM::Position::create(realm(), *m_text_node, selection_end)); - auto selection = document().get_selection(); - if (!selection || selection->range_count() == 0) - return; - - MUST(selection->set_base_and_extent(*m_text_node, selection_start, *m_text_node, selection_end)); + if (auto selection = document().get_selection()) + MUST(selection->set_base_and_extent(*m_text_node, selection_start, *m_text_node, selection_end)); } }