From fdaf2146adae861ed3c3a42f0044e589e9d86afd Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Mon, 8 Apr 2013 21:33:25 -0400 Subject: Fix #13393. Avoid IE9 activeElement of death. (Cherry picked from 85fc5878b3c6af73f42d61eedf73013e7faae408) Conflicts: src/event.js --- src/event.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/event.js') diff --git a/src/event.js b/src/event.js index fae4f0765..5151d2bd7 100644 --- a/src/event.js +++ b/src/event.js @@ -12,6 +12,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. @@ -555,7 +561,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 ) { try { this.focus(); return false; @@ -570,7 +576,7 @@ jQuery.event = { }, blur: { trigger: function() { - if ( this === document.activeElement && this.blur ) { + if ( this === safeActiveElement() && this.blur ) { this.blur(); return false; } -- cgit v1.2.3