mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Core: Added asynchronous focus. Fixed #3559 - :focusable, :tabbable, setFocus().
This commit is contained in:
parent
15788355fa
commit
cedf663e2f
@ -25,4 +25,27 @@ test("attr - aria", function() {
|
|||||||
equals(el.attr('aria-expanded'), 'false', 'aria expanded is false');
|
equals(el.attr('aria-expanded'), 'false', 'aria expanded is false');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('focus', function() {
|
||||||
|
expect(3);
|
||||||
|
|
||||||
|
var el = $('#inputTabindex0'),
|
||||||
|
// used to remove focus from the main element
|
||||||
|
other = $('#inputTabindex10');
|
||||||
|
|
||||||
|
// test original functionality
|
||||||
|
el.focus(function() {
|
||||||
|
ok(true, 'event triggered');
|
||||||
|
});
|
||||||
|
el.focus();
|
||||||
|
other.focus();
|
||||||
|
|
||||||
|
// trigger event handler + callback
|
||||||
|
stop();
|
||||||
|
el.focus(500, function() {
|
||||||
|
start();
|
||||||
|
ok(true, 'callback triggered');
|
||||||
|
});
|
||||||
|
other.focus();
|
||||||
|
});
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
@ -135,6 +135,19 @@ if (isFF2) {
|
|||||||
|
|
||||||
//jQuery plugins
|
//jQuery plugins
|
||||||
$.fn.extend({
|
$.fn.extend({
|
||||||
|
_focus: $.fn.focus,
|
||||||
|
focus: function(delay, fn) {
|
||||||
|
return typeof delay === 'number'
|
||||||
|
? this.each(function() {
|
||||||
|
var elem = this;
|
||||||
|
setTimeout(function() {
|
||||||
|
$(elem).focus();
|
||||||
|
(fn && fn.call(elem));
|
||||||
|
}, delay);
|
||||||
|
})
|
||||||
|
: this._focus.apply(this, arguments);
|
||||||
|
},
|
||||||
|
|
||||||
remove: function() {
|
remove: function() {
|
||||||
// Safari has a native remove event which actually removes DOM elements,
|
// Safari has a native remove event which actually removes DOM elements,
|
||||||
// so we have to use triggerHandler instead of trigger (#3037).
|
// so we have to use triggerHandler instead of trigger (#3037).
|
||||||
|
Loading…
Reference in New Issue
Block a user