diff --git a/Tests/LibWeb/Text/expected/HTML/HTMLInputElement-blur.txt b/Tests/LibWeb/Text/expected/HTML/HTMLInputElement-blur.txt new file mode 100644 index 00000000000..aaecaf93c4a --- /dev/null +++ b/Tests/LibWeb/Text/expected/HTML/HTMLInputElement-blur.txt @@ -0,0 +1 @@ +PASS (didn't crash) diff --git a/Tests/LibWeb/Text/input/HTML/HTMLInputElement-blur.html b/Tests/LibWeb/Text/input/HTML/HTMLInputElement-blur.html new file mode 100644 index 00000000000..cb1aec6bec9 --- /dev/null +++ b/Tests/LibWeb/Text/input/HTML/HTMLInputElement-blur.html @@ -0,0 +1,11 @@ + + + + diff --git a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp index 0c2c957df8e..d14771f5845 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLInputElement.cpp @@ -1187,11 +1187,12 @@ void HTMLInputElement::did_receive_focus() void HTMLInputElement::did_lose_focus() { - if (m_text_node) + if (m_text_node) { m_text_node->invalidate_style(DOM::StyleInvalidationReason::DidLoseFocus); - if (auto* paintable = m_text_node->paintable()) - paintable->set_selected(false); + if (auto* paintable = m_text_node->paintable()) + paintable->set_selected(false); + } if (m_placeholder_text_node) m_placeholder_text_node->invalidate_style(DOM::StyleInvalidationReason::DidLoseFocus);