File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Expand file tree Collapse file tree 1 file changed +18
-5
lines changed Original file line number Diff line number Diff line change @@ -169,7 +169,8 @@ $.widget( "ui.dialog", {
169
169
enable : $ . noop ,
170
170
171
171
close : function ( event ) {
172
- var that = this ;
172
+ var activeElement ,
173
+ that = this ;
173
174
174
175
if ( ! this . _isOpen || this . _trigger ( "beforeClose" , event ) === false ) {
175
176
return ;
@@ -179,10 +180,22 @@ $.widget( "ui.dialog", {
179
180
this . _destroyOverlay ( ) ;
180
181
181
182
if ( ! this . opener . filter ( ":focusable" ) . focus ( ) . length ) {
182
- // Hiding a focused element doesn't trigger blur in WebKit
183
- // so in case we have nothing to focus on, explicitly blur the active element
184
- // https://bugs.webkit.org/show_bug.cgi?id=47182
185
- $ ( this . document [ 0 ] . activeElement ) . blur ( ) ;
183
+
184
+ // support: IE9
185
+ // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
186
+ try {
187
+ activeElement = this . document [ 0 ] . activeElement ;
188
+
189
+ // Support: IE9, IE10
190
+ // If the <body> is blurred, IE will switch windows, see #4520
191
+ if ( activeElement && activeElement . nodeName . toLowerCase ( ) !== "body" ) {
192
+
193
+ // Hiding a focused element doesn't trigger blur in WebKit
194
+ // so in case we have nothing to focus on, explicitly blur the active element
195
+ // https://bugs.webkit.org/show_bug.cgi?id=47182
196
+ $ ( activeElement ) . blur ( ) ;
197
+ }
198
+ } catch ( error ) { }
186
199
}
187
200
188
201
this . _hide ( this . uiDialog , this . options . hide , function ( ) {
You can’t perform that action at this time.
0 commit comments