🌐 AI搜索 & 代理 主页
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -746,10 +746,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
Expand Down
16 changes: 16 additions & 0 deletions test/unit/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -3325,6 +3325,22 @@ QUnit.test( "focus change during a focus handler (gh-4382)", function( assert )
} );
} );

QUnit.test( "trigger(focus) works after .on(focus).off(focus) (gh-4867)", function( assert ) {
assert.expect( 1 );

var input = jQuery( "<input />" );

input.appendTo( "#qunit-fixture" );

input
.on( "focus", function() {} )
.off( "focus" );

input.trigger( "focus" );

assert.equal( document.activeElement, input[ 0 ], "input has focus" );
} );

// TODO replace with an adaptation of
// https://github.com/jquery/jquery/pull/1367/files#diff-a215316abbaabdf71857809e8673ea28R2464
( function() {
Expand Down