Commit 5f325b1b authored by Dave Methvin's avatar Dave Methvin

Ref #14180, let focusin/out work on non-element targets.

(cherry picked from commit c2aca17d)

Conflicts:
	src/event.js
parent 9ca87af4
...@@ -899,7 +899,7 @@ if ( !support.focusinBubbles ) { ...@@ -899,7 +899,7 @@ if ( !support.focusinBubbles ) {
jQuery.event.special[ fix ] = { jQuery.event.special[ fix ] = {
setup: function() { setup: function() {
var doc = this.ownerDocument, var doc = this.ownerDocument || this,
attaches = jQuery._data( doc, fix ); attaches = jQuery._data( doc, fix );
if ( !attaches ) { if ( !attaches ) {
...@@ -908,7 +908,7 @@ if ( !support.focusinBubbles ) { ...@@ -908,7 +908,7 @@ if ( !support.focusinBubbles ) {
jQuery._data( doc, fix, ( attaches || 0 ) + 1 ); jQuery._data( doc, fix, ( attaches || 0 ) + 1 );
}, },
teardown: function() { teardown: function() {
var doc = this.ownerDocument, var doc = this.ownerDocument || this,
attaches = jQuery._data( doc, fix ) - 1; attaches = jQuery._data( doc, fix ) - 1;
if ( !attaches ) { if ( !attaches ) {
......
...@@ -2462,6 +2462,19 @@ test("fixHooks extensions", function() { ...@@ -2462,6 +2462,19 @@ test("fixHooks extensions", function() {
jQuery.event.fixHooks.click = saved; jQuery.event.fixHooks.click = saved;
}); });
test( "focusin using non-element targets", function() {
expect( 2 );
jQuery( document ).on( "focusin", function( e ) {
ok( e.type === "focusin", "got a focusin event on a document" );
}).trigger( "focusin" ).off( "focusin" );
jQuery( window ).on( "focusin", function( e ) {
ok( e.type === "focusin", "got a focusin event on a window" );
}).trigger( "focusin" ).off( "focusin" );
});
testIframeWithCallback( "focusin from an iframe", "event/focusinCrossFrame.html", function( frameDoc ) { testIframeWithCallback( "focusin from an iframe", "event/focusinCrossFrame.html", function( frameDoc ) {
expect(1); expect(1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment