Permalink
Browse files

Core: Move safeActiveElement into its own module

Ref #9647
  • Loading branch information...
arschmitz committed Jul 15, 2015
1 parent 0a9df3a commit 2b84531ae9331f60e4d739fabca6d78abde89ae1
Showing with 52 additions and 36 deletions.
  1. +3 −2 ui/autocomplete.js
  2. +1 −29 ui/core.js
  3. +2 −2 ui/dialog.js
  4. +1 −0 ui/draggable.js
  5. +3 −2 ui/menu.js
  6. +40 −0 ui/safe-active-element.js
  7. +1 −1 ui/spinner.js
  8. +1 −0 ui/tabs.js
@@ -23,11 +23,12 @@
define( [
"jquery",
"./core",
"./version",
"./keycode",
"./widget",
"./position",
"./version",
"./menu"
"./menu",
"./safe-active-element"
], factory );
} else {
@@ -29,6 +29,7 @@
"./labels",
"./jquery-1-7",
"./plugin",
"./safe-active-element",
"./version"
], factory );
} else {
@@ -40,35 +41,6 @@
$.extend( $.ui, {
// Internal use only
safeActiveElement: function( document ) {
var activeElement;
// Support: IE 9 only
// IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
try {
activeElement = document.activeElement;
} catch ( error ) {
activeElement = document.body;
}
// Support: IE 9 - 11 only
// IE may return null instead of an element
// Interestingly, this only seems to occur when NOT in an iframe
if ( !activeElement ) {
activeElement = document.body;
}
// Support: IE 11 only
// IE11 returns a seemingly empty object in some cases when accessing
// document.activeElement from an <iframe>
if ( !activeElement.nodeName ) {
activeElement = document.body;
}
return activeElement;
},
// Internal use only
safeBlur: function( element ) {
@@ -22,7 +22,7 @@
// AMD. Register as an anonymous module.
define( [
"jquery",
"./core",
"./version",
"./keycode",
"./widget",
"./button",
@@ -31,7 +31,7 @@
"./mouse",
"./position",
"./resizable",
"./version"
"./safe-active-element"
], factory );
} else {
@@ -24,6 +24,7 @@
"./data",
"./mouse",
"./plugin",
"./safe-active-element",
"./version",
"./widget"
], factory );
@@ -25,8 +25,9 @@
"./core",
"./version",
"./keycode",
"./widget",
"./position"
"./position",
"./safe-active-element",
"./widget"
], factory );
} else {
@@ -0,0 +1,40 @@
( function( factory ) {
if ( typeof define === "function" && define.amd ) {
// AMD. Register as an anonymous module.
define( [ "jquery", "./version" ], factory );
} else {
// Browser globals
factory( jQuery );
}
} ( function( $ ) {
return $.ui.safeActiveElement = function( document ) {
var activeElement;
// Support: IE 9 only
// IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
try {
activeElement = document.activeElement;
} catch ( error ) {
activeElement = document.body;
}
// Support: IE 9 - 11 only
// IE may return null instead of an element
// Interestingly, this only seems to occur when NOT in an iframe
if ( !activeElement ) {
activeElement = document.body;
}
// Support: IE 11 only
// IE11 returns a seemingly empty object in some cases when accessing
// document.activeElement from an <iframe>
if ( !activeElement.nodeName ) {
activeElement = document.body;
}
return activeElement;
};
} ) );
@@ -22,9 +22,9 @@
// AMD. Register as an anonymous module.
define( [
"jquery",
"./core",
"./version",
"./keycode",
"./safe-active-element",
"./widget",
"./button"
], factory );
@@ -25,6 +25,7 @@
"./core",
"./escape-selector",
"./keycode",
"./safe-active-element",
"./version",
"./widget"
], factory );

0 comments on commit 2b84531

Please sign in to comment.