@@ -439,6 +439,20 @@ function _normalizeArguments(effect, options, speed, callback) {
439
439
return [ effect , options , speed , callback ] ;
440
440
}
441
441
442
+ function standardSpeed ( speed ) {
443
+ // valid standard speeds
444
+ if ( ! speed || typeof speed === "number" || $ . fx . speeds [ speed ] ) {
445
+ return true ;
446
+ }
447
+
448
+ // invalid strings - treat as "normal" speed
449
+ if ( typeof speed === "string" && ! $ . effects [ speed ] ) {
450
+ return true ;
451
+ }
452
+
453
+ return false ;
454
+ }
455
+
442
456
$ . fn . extend ( {
443
457
effect : function ( effect , options , speed , callback ) {
444
458
var args = _normalizeArguments . apply ( this , arguments ) ,
@@ -455,7 +469,7 @@ $.fn.extend({
455
469
456
470
_show : $ . fn . show ,
457
471
show : function ( speed ) {
458
- if ( ! speed || typeof speed == 'number' || $ . fx . speeds [ speed ] || ! $ . effects [ speed ] ) {
472
+ if ( standardSpeed ( speed ) ) {
459
473
return this . _show . apply ( this , arguments ) ;
460
474
} else {
461
475
var args = _normalizeArguments . apply ( this , arguments ) ;
@@ -466,7 +480,7 @@ $.fn.extend({
466
480
467
481
_hide : $ . fn . hide ,
468
482
hide : function ( speed ) {
469
- if ( ! speed || typeof speed == 'number' || $ . fx . speeds [ speed ] || ! $ . effects [ speed ] ) {
483
+ if ( standardSpeed ( speed ) ) {
470
484
return this . _hide . apply ( this , arguments ) ;
471
485
} else {
472
486
var args = _normalizeArguments . apply ( this , arguments ) ;
@@ -478,8 +492,7 @@ $.fn.extend({
478
492
// jQuery core overloads toggle and creates _toggle
479
493
__toggle : $ . fn . toggle ,
480
494
toggle : function ( speed ) {
481
- if ( ! speed || typeof speed == 'number' || $ . fx . speeds [ speed ] || ! $ . effects [ speed ] ||
482
- typeof speed == 'boolean' || $ . isFunction ( speed ) ) {
495
+ if ( standardSpeed ( speed ) || typeof speed === "boolean" || $ . isFunction ( speed ) ) {
483
496
return this . __toggle . apply ( this , arguments ) ;
484
497
} else {
485
498
var args = _normalizeArguments . apply ( this , arguments ) ;
0 commit comments