Standardized the type checks across core. isFunction and isArray now use Object.prototype.toString to verify the type, .constructor use was removed in favor of typeof, typeof checks now use ===, undefined checks use === undefined. All of this is outlined in the new style guidelines: http://docs.jquery.com/JQuery_Core_Style_Guidelines#Type_Checks. Fixes bug #3618.

This commit is contained in:
John Resig 2008-11-17 16:32:05 +00:00
parent 0aa8d40cdf
commit ab551c2b14
6 changed files with 52 additions and 54 deletions

View file

@ -117,7 +117,7 @@ jQuery.fn.extend({
type = "fx";
}
if ( !type || (typeof type == "string" && !fn) )
if ( !type || (typeof type === "string" && !fn) )
return queue( this[0], type );
return this.each(function(){
@ -201,14 +201,14 @@ jQuery.fn.dequeue = function(type){
jQuery.extend({
speed: function(speed, easing, fn) {
var opt = speed && speed.constructor == Object ? speed : {
var opt = typeof speed === "object" ? speed : {
complete: fn || !fn && easing ||
jQuery.isFunction( speed ) && speed,
duration: speed,
easing: fn && easing || easing && easing.constructor != Function && easing
easing: fn && easing || jQuery.isFunction(easing) && easing
};
opt.duration = jQuery.fx.off ? 0 : typeof opt.duration == 'number' ? opt.duration :
opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
jQuery.fx.speeds[opt.duration] || jQuery.fx.speeds._default;
// Queueing