aboutsummaryrefslogtreecommitdiffstats
path: root/ui/dialog.js
diff options
context:
space:
mode:
Diffstat (limited to 'ui/dialog.js')
-rw-r--r--ui/dialog.js26
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 ) {