mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 13:19:05 +00:00
LibWeb: Don't crash when input with no associated text node loses focus
This commit is contained in:
parent
5010e42cd3
commit
56441fe3e6
Notes:
github-actions[bot]
2024-11-04 10:09:31 +00:00
Author: https://github.com/tcl3
Commit: 56441fe3e6
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2153
Reviewed-by: https://github.com/gmta ✅
3 changed files with 16 additions and 3 deletions
|
@ -0,0 +1 @@
|
||||||
|
PASS (didn't crash)
|
11
Tests/LibWeb/Text/input/HTML/HTMLInputElement-blur.html
Normal file
11
Tests/LibWeb/Text/input/HTML/HTMLInputElement-blur.html
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<input type="checkbox">
|
||||||
|
<script src="../include.js"></script>
|
||||||
|
<script>
|
||||||
|
test(() => {
|
||||||
|
const input = document.querySelector("input");
|
||||||
|
input.focus();
|
||||||
|
input.blur();
|
||||||
|
println("PASS (didn't crash)");
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -1187,11 +1187,12 @@ void HTMLInputElement::did_receive_focus()
|
||||||
|
|
||||||
void HTMLInputElement::did_lose_focus()
|
void HTMLInputElement::did_lose_focus()
|
||||||
{
|
{
|
||||||
if (m_text_node)
|
if (m_text_node) {
|
||||||
m_text_node->invalidate_style(DOM::StyleInvalidationReason::DidLoseFocus);
|
m_text_node->invalidate_style(DOM::StyleInvalidationReason::DidLoseFocus);
|
||||||
|
|
||||||
if (auto* paintable = m_text_node->paintable())
|
if (auto* paintable = m_text_node->paintable())
|
||||||
paintable->set_selected(false);
|
paintable->set_selected(false);
|
||||||
|
}
|
||||||
|
|
||||||
if (m_placeholder_text_node)
|
if (m_placeholder_text_node)
|
||||||
m_placeholder_text_node->invalidate_style(DOM::StyleInvalidationReason::DidLoseFocus);
|
m_placeholder_text_node->invalidate_style(DOM::StyleInvalidationReason::DidLoseFocus);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue