-
-
Save jzaefferer/0cc41a3c2fd12494d139 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tests/unit/core/core.js | |
diff --git a/tests/unit/core/core.js b/tests/unit/core/core.js | |
index acacfab..1b1dcba 100644 | |
--- a/tests/unit/core/core.js | |
+++ b/tests/unit/core/core.js | |
@@ -4,34 +4,6 @@ module( "core - jQuery extensions" ); | |
TestHelpers.testJshint( "core" ); | |
-asyncTest( "focus - original functionality", function() { | |
- expect( 1 ); | |
- $( "#inputTabindex0" ) | |
- .one( "focus", function() { | |
- ok( true, "event triggered" ); | |
- start(); | |
- }) | |
- .focus(); | |
-}); | |
- | |
-asyncTest( "focus", function() { | |
- expect( 2 ); | |
- | |
- // support: IE 8 | |
- // IE sometimes gets confused about what's focused if we don't explicitly | |
- // focus a different element first | |
- $( "body" ).focus(); | |
- | |
- $( "#inputTabindex0" ) | |
- .one( "focus", function() { | |
- ok( true, "event triggered" ); | |
- start(); | |
- }) | |
- .focus( 500, function() { | |
- ok( true, "callback triggered" ); | |
- }); | |
-}); | |
- | |
test( "innerWidth - getter", function() { | |
expect( 2 ); | |
var el = $( "#dimensions" ); | |
ui/core.js | |
diff --git a/ui/core.js b/ui/core.js | |
index 7323bae..52e706f 100644 | |
--- a/ui/core.js | |
+++ b/ui/core.js | |
@@ -49,18 +49,11 @@ $.extend( $.ui, { | |
// plugins | |
$.fn.extend({ | |
focus: (function( orig ) { | |
- return function( delay, fn ) { | |
- return typeof delay === "number" ? | |
- this.each(function() { | |
- var elem = this; | |
- setTimeout(function() { | |
- $( elem ).focus(); | |
- if ( fn ) { | |
- fn.call( elem ); | |
- } | |
- }, delay ); | |
- }) : | |
- orig.apply( this, arguments ); | |
+ return function( delay ) { | |
+ if ( typeof delay === "number" ) { | |
+ throw new Error("Delayed focus is deprecated, use timeouts and call focus yourself"); | |
+ } | |
+ return orig.apply( this, arguments ); | |
}; | |
})( $.fn.focus ), | |
ui/dialog.js | |
diff --git a/ui/dialog.js b/ui/dialog.js | |
index 07100c9..118ce1f 100644 | |
--- a/ui/dialog.js | |
+++ b/ui/dialog.js | |
@@ -342,10 +342,14 @@ return $.widget( "ui.dialog", { | |
last = tabbables.filter( ":last" ); | |
if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) { | |
- first.focus( 1 ); | |
+ this.delay(function() { | |
+ first.focus(); | |
+ }); | |
event.preventDefault(); | |
} else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) { | |
- last.focus( 1 ); | |
+ this.delay(function() { | |
+ first.focus(); | |
+ }); | |
event.preventDefault(); | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment