aboutsummaryrefslogtreecommitdiffstats
path: root/src/event.js
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2021-05-10 18:59:14 +0200
committerMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2021-05-10 19:13:25 +0200
commitb3e4a7eb16f68586e25a1f27f7f7c5ecba013261 (patch)
tree7f6b0cb83fe707febc524dc4cfc25273aa481cf0 /src/event.js
parent752b8981f8ee410d4c2cbada18a9afa2d880263b (diff)
downloadjquery-b3e4a7eb16f68586e25a1f27f7f7c5ecba013261.tar.gz
jquery-b3e4a7eb16f68586e25a1f27f7f7c5ecba013261.zip
Event: Don't break focus triggering after `.on(focus).off(focus)`
The `_default` function in the special event settings for focus/blur has always returned `true` since gh-4813 as the event was already being fired from `leverageNative`. However, that only works if there's an active handler on that element; this made a quick consecutive call: ```js elem.on( "focus", function() {} ).off( "focus" ); ``` make subsequent `.trigger( "focus" )` calls to not do any triggering. The solution, already used in a similar `_default` method for the `click` event, is to check for the `dataPriv` entry on the element for the focus event (similarly for blur). Fixes gh-4867 Closes gh-4885 (cherry picked from commit e539bac79e666bba95bba86d690b4e609dca2286)
Diffstat (limited to 'src/event.js')
-rw-r--r--src/event.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/event.js b/src/event.js
index a954400a3..add100b84 100644
--- a/src/event.js
+++ b/src/event.js
@@ -778,10 +778,10 @@ jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateTyp
return true;
},
- // Suppress native focus or blur as it's already being fired
- // in leverageNative.
- _default: function() {
- return true;
+ // Suppress native focus or blur if we're currently inside
+ // a leveraged native-event stack
+ _default: function( event ) {
+ return dataPriv.get( event.target, type );
},
delegateType: delegateType