Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Ref #14180, let focusin/out work on non-element targets.
  • Loading branch information
dmethvin committed Nov 14, 2013
1 parent 498e0e6 commit c2aca17
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/event.js
Expand Up @@ -728,7 +728,7 @@ if ( !support.focusinBubbles ) {

jQuery.event.special[ fix ] = {
setup: function() {
var doc = this.ownerDocument,
var doc = this.ownerDocument || this,
attaches = data_priv.access( doc, fix );

if ( !attaches ) {
Expand All @@ -737,7 +737,7 @@ if ( !support.focusinBubbles ) {
data_priv.access( doc, fix, ( attaches || 0 ) + 1 );
},
teardown: function() {
var doc = this.ownerDocument,
var doc = this.ownerDocument || this,
attaches = data_priv.access( doc, fix ) - 1;

if ( !attaches ) {
Expand Down
13 changes: 13 additions & 0 deletions test/unit/event.js
Expand Up @@ -2374,6 +2374,19 @@ test("fixHooks extensions", function() {
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 ) {
expect(1);

Expand Down

0 comments on commit c2aca17

Please sign in to comment.