@@ -194,8 +194,7 @@ $.widget( "ui.dialog", {
194194 enable : $ . noop ,
195195
196196 close : function ( event ) {
197- var activeElement ,
198- that = this ;
197+ var that = this ;
199198
200199 if ( ! this . _isOpen || this . _trigger ( "beforeClose" , event ) === false ) {
201200 return ;
@@ -208,21 +207,10 @@ $.widget( "ui.dialog", {
208207
209208 if ( ! this . opener . filter ( ":focusable" ) . focus ( ) . length ) {
210209
211- // support: IE9
212- // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
213- try {
214- activeElement = this . document [ 0 ] . activeElement ;
215-
216- // Support: IE9, IE10
217- // If the <body> is blurred, IE will switch windows, see #4520
218- if ( activeElement && activeElement . nodeName . toLowerCase ( ) !== "body" ) {
219-
220- // Hiding a focused element doesn't trigger blur in WebKit
221- // so in case we have nothing to focus on, explicitly blur the active element
222- // https://bugs.webkit.org/show_bug.cgi?id=47182
223- $ ( activeElement ) . blur ( ) ;
224- }
225- } catch ( error ) { }
210+ // Hiding a focused element doesn't trigger blur in WebKit
211+ // so in case we have nothing to focus on, explicitly blur the active element
212+ // https://bugs.webkit.org/show_bug.cgi?id=47182
213+ $ . ui . safeBlur ( $ . ui . safeActiveElement ( this . document [ 0 ] ) ) ;
226214 }
227215
228216 this . _hide ( this . uiDialog , this . options . hide , function ( ) {
@@ -266,7 +254,7 @@ $.widget( "ui.dialog", {
266254 }
267255
268256 this . _isOpen = true ;
269- this . opener = $ ( this . document [ 0 ] . activeElement ) ;
257+ this . opener = $ ( $ . ui . safeActiveElement ( this . document [ 0 ] ) ) ;
270258
271259 this . _size ( ) ;
272260 this . _position ( ) ;
@@ -322,7 +310,7 @@ $.widget( "ui.dialog", {
322310
323311 _keepFocus : function ( event ) {
324312 function checkFocus ( ) {
325- var activeElement = this . document [ 0 ] . activeElement ,
313+ var activeElement = $ . ui . safeActiveElement ( this . document [ 0 ] ) ,
326314 isActive = this . uiDialog [ 0 ] === activeElement ||
327315 $ . contains ( this . uiDialog [ 0 ] , activeElement ) ;
328316 if ( ! isActive ) {
0 commit comments