diff options
author | Scott González <scott.gonzalez@gmail.com> | 2015-03-09 16:03:22 -0400 |
---|---|---|
committer | Scott González <scott.gonzalez@gmail.com> | 2015-03-12 07:35:27 -0400 |
commit | f33027840cdac5152599da66635981bbe68c6bda (patch) | |
tree | a52f4063e0a2aab02af24d26eee590eba797882e /ui/dialog.js | |
parent | 6111b17710ab4e14bb119e735de9cfa9285badab (diff) | |
download | jquery-ui-f33027840cdac5152599da66635981bbe68c6bda.tar.gz jquery-ui-f33027840cdac5152599da66635981bbe68c6bda.zip |
Core: Add methods to work around IE active element bugs
Closes gh-1478
Diffstat (limited to 'ui/dialog.js')
-rw-r--r-- | ui/dialog.js | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/ui/dialog.js b/ui/dialog.js index 8f2fc583c..4716f44b1 100644 --- a/ui/dialog.js +++ b/ui/dialog.js @@ -194,8 +194,7 @@ $.widget( "ui.dialog", { enable: $.noop, close: function( event ) { - var activeElement, - that = this; + var that = this; if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) { return; @@ -208,21 +207,10 @@ $.widget( "ui.dialog", { if ( !this.opener.filter( ":focusable" ).focus().length ) { - // support: IE9 - // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe> - try { - activeElement = this.document[ 0 ].activeElement; - - // Support: IE9, IE10 - // If the <body> is blurred, IE will switch windows, see #4520 - if ( activeElement && activeElement.nodeName.toLowerCase() !== "body" ) { - - // Hiding a focused element doesn't trigger blur in WebKit - // so in case we have nothing to focus on, explicitly blur the active element - // https://bugs.webkit.org/show_bug.cgi?id=47182 - $( activeElement ).blur(); - } - } catch ( error ) {} + // Hiding a focused element doesn't trigger blur in WebKit + // so in case we have nothing to focus on, explicitly blur the active element + // https://bugs.webkit.org/show_bug.cgi?id=47182 + $.ui.safeBlur( $.ui.safeActiveElement( this.document[ 0 ] ) ); } this._hide( this.uiDialog, this.options.hide, function() { @@ -266,7 +254,7 @@ $.widget( "ui.dialog", { } this._isOpen = true; - this.opener = $( this.document[ 0 ].activeElement ); + this.opener = $( $.ui.safeActiveElement( this.document[ 0 ] ) ); this._size(); this._position(); @@ -322,7 +310,7 @@ $.widget( "ui.dialog", { _keepFocus: function( event ) { function checkFocus() { - var activeElement = this.document[0].activeElement, + var activeElement = $.ui.safeActiveElement( this.document[0] ), isActive = this.uiDialog[0] === activeElement || $.contains( this.uiDialog[0], activeElement ); if ( !isActive ) { |