aboutsummaryrefslogtreecommitdiffstats
path: root/src/event.js
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2020-10-19 21:17:51 +0200
committerGitHub <noreply@github.com>2020-10-19 21:17:51 +0200
commit5c2d08704e289dd2745bcb0557b35a9c0e6af4a4 (patch)
treeeb5fb38fac065c649ec94bae2b0130bc4a6197b6 /src/event.js
parenta503c691dc06c59acdafef6e54eca2613c6e4032 (diff)
downloadjquery-5c2d08704e289dd2745bcb0557b35a9c0e6af4a4.tar.gz
jquery-5c2d08704e289dd2745bcb0557b35a9c0e6af4a4.zip
Event: Don't crash if an element is removed on blur
In Chrome, if an element having a `focusout` handler is blurred by clicking outside of it, it invokes the handler synchronously. If that handler calls `.remove()` on the element, the data is cleared, leaving private data undefined. We're reading a property from that data so we need to guard against this. Fixes gh-4417 Closes gh-4799
Diffstat (limited to 'src/event.js')
-rw-r--r--src/event.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/event.js b/src/event.js
index b8c5e96fe..4418fbbbf 100644
--- a/src/event.js
+++ b/src/event.js
@@ -558,7 +558,13 @@ function leverageNative( el, type, expectSync ) {
// Cancel the outer synthetic event
event.stopImmediatePropagation();
event.preventDefault();
- return result.value;
+
+ // Support: Chrome 86+
+ // In Chrome, if an element having a focusout handler is blurred by
+ // clicking outside of it, it invokes the handler synchronously. If
+ // that handler calls `.remove()` on the element, the data is cleared,
+ // leaving `result` undefined. We need to guard against this.
+ return result && result.value;
}
// If this is an inner synthetic event for an event with a bubbling surrogate