mirror of
https://github.com/jquery/jquery.git
synced 2026-04-20 03:01:22 -04:00
Fix #13393. Avoid IE9 activeElement of death.
This commit is contained in:
10
src/event.js
10
src/event.js
@@ -11,6 +11,12 @@ function returnFalse() {
|
||||
return false;
|
||||
}
|
||||
|
||||
function safeActiveElement() {
|
||||
try {
|
||||
return document.activeElement;
|
||||
} catch ( err ) { }
|
||||
}
|
||||
|
||||
/*
|
||||
* Helper functions for managing events -- not part of the public interface.
|
||||
* Props to Dean Edwards' addEvent library for many of the ideas.
|
||||
@@ -522,7 +528,7 @@ jQuery.event = {
|
||||
focus: {
|
||||
// Fire native event if possible so blur/focus sequence is correct
|
||||
trigger: function() {
|
||||
if ( this !== document.activeElement && this.focus ) {
|
||||
if ( this !== safeActiveElement() && this.focus ) {
|
||||
this.focus();
|
||||
return false;
|
||||
}
|
||||
@@ -531,7 +537,7 @@ jQuery.event = {
|
||||
},
|
||||
blur: {
|
||||
trigger: function() {
|
||||
if ( this === document.activeElement && this.blur ) {
|
||||
if ( this === safeActiveElement() && this.blur ) {
|
||||
this.blur();
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user