Side navigation
Ticket #3618: 3618.2.diff
File 3618.2.diff, 14.2 KB (added by john, November 17, 2008 04:19PM UTC)
All primitives are checked with typeof, undefined is checked with === undefined, objects are checked with isFunction or isArray, object checks use Object.prototype.toString.
Index: src/offset.js
===================================================================
--- src/offset.js (revision 5946)
+++ src/offset.js (working copy)
@@ -133,7 +133,7 @@
jQuery.fn[ method ] = function(val) {
if (!this[0]) return;
- return val != undefined ?
+ return val !== undefined ?
// Set the scroll offset
this.each(function() {
Index: src/core.js
===================================================================
--- src/core.js (revision 5946)
+++ src/core.js (working copy)
@@ -41,7 +41,7 @@
return this;
}
// Handle HTML strings
- if ( typeof selector == "string" ) {
+ if ( typeof selector === "string" ) {
// Are we dealing with HTML string or an ID?
var match = quickExpr.exec( selector );
@@ -93,7 +93,7 @@
// Get the Nth element in the matched element set OR
// Get the whole matched element set as a clean array
get: function( num ) {
- return num == undefined ?
+ return num === undefined ?
// Return a 'clean' array
jQuery.makeArray( this ) :
@@ -150,7 +150,7 @@
var options = name;
// Look for the case where we're accessing a style value
- if ( name.constructor == String )
+ if ( typeof name === "string" )
if ( value === undefined )
return this[0] && jQuery[ type || "attr" ]( this[0], name );
@@ -180,7 +180,7 @@
},
text: function( text ) {
- if ( typeof text != "object" && text != null )
+ if ( typeof text !== "object" && text != null )
return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
var ret = "";
@@ -292,7 +292,7 @@
// removeData doesn't work here, IE removes it from the original as well
// this is primarily for IE but the data expando shouldn't be copied over in any browser
var clone = ret.find("*").andSelf().each(function(){
- if ( this[ expando ] != undefined )
+ if ( this[ expando ] !== undefined )
this[ expando ] = null;
});
@@ -323,7 +323,7 @@
},
not: function( selector ) {
- if ( selector.constructor == String )
+ if ( typeof selector === "string" )
// test special case where just one selector is passed in
if ( isSimple.test( selector ) )
return this.pushStack( jQuery.multiFilter( selector, this, true ) );
@@ -339,7 +339,7 @@
add: function( selector ) {
return this.pushStack( jQuery.unique( jQuery.merge(
this.get(),
- typeof selector == 'string' ?
+ typeof selector === "string" ?
jQuery( selector ) :
jQuery.makeArray( selector )
)));
@@ -354,7 +354,7 @@
},
val: function( value ) {
- if ( value == undefined ) {
+ if ( value === undefined ) {
var elem = this[0];
if ( elem ) {
@@ -400,7 +400,7 @@
return undefined;
}
- if( value.constructor == Number )
+ if ( typeof value === "number" )
value += '';
return this.each(function(){
@@ -428,7 +428,7 @@
},
html: function( value ) {
- return value == undefined ?
+ return value === undefined ?
(this[0] ?
this[0].innerHTML :
null) :
@@ -550,7 +550,7 @@
var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;
// Handle a deep copy situation
- if ( target.constructor == Boolean ) {
+ if ( typeof target === "boolean" ) {
deep = target;
target = arguments[1] || {};
// skip the boolean and the target
@@ -558,7 +558,7 @@
}
// Handle case when target is a string or something (possible in deep copy)
- if ( typeof target != "object" && typeof target != "function" )
+ if ( typeof target !== "object" && !jQuery.isFunction(target) )
target = {};
// extend jQuery itself if only one argument is passed
@@ -579,7 +579,7 @@
continue;
// Recurse if we're merging object values
- if ( deep && copy && typeof copy == "object" && !copy.nodeType )
+ if ( deep && copy && typeof copy === "object" && !copy.nodeType )
target[ name ] = jQuery.extend( deep,
// Never move original objects, clone them
src || ( copy.length != null ? [ ] : { } )
@@ -599,7 +599,8 @@
// exclude the following css properties to add px
exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
// cache defaultView
- defaultView = document.defaultView || {};
+ defaultView = document.defaultView || {},
+ toString = Object.prototype.toString;
jQuery.extend({
noConflict: function( deep ) {
@@ -611,19 +612,15 @@
return jQuery;
},
- // See test/unit/core.js for details concerning this function.
+ // See test/unit/core.js for details concerning isFunction.
// Since version 1.3, DOM methods and functions like alert
// aren't supported. They return false on IE (#2968).
-
- // Memory leaks appear in IE6 when applying instanceof
- // to the window, document or any other COM object (#3485)
- // http://ajaxian.com/archives/working-aroung-the-instanceof-memory-leak
- isFunction: function( fn ) {
- return !!fn && !!fn.hasOwnProperty && fn instanceof Function;
+ isFunction: function( obj ) {
+ return toString.call(obj) === "[object Function]";
},
-
- isArray: function( arr ){
- return !!arr && arr.constructor == Array;
+
+ isArray: function( obj ) {
+ return toString.call(obj) === "[object Array]";
},
// check if an element is in a (or is an) XML document
@@ -732,7 +729,7 @@
var name, i = 0, length = object.length;
if ( args ) {
- if ( length == undefined ) {
+ if ( length === undefined ) {
for ( name in object )
if ( callback.apply( object[ name ], args ) === false )
break;
@@ -743,7 +740,7 @@
// A special, fast, case for the most common use of each
} else {
- if ( length == undefined ) {
+ if ( length === undefined ) {
for ( name in object )
if ( callback.call( object[ name ], name, object[ name ] ) === false )
break;
@@ -761,7 +758,7 @@
value = value.call( elem, i );
// Handle passing in a number to a CSS property
- return value && value.constructor == Number && type == "curCSS" && !exclude.test( name ) ?
+ return typeof value === "number" && type == "curCSS" && !exclude.test( name ) ?
value + "px" :
value;
},
@@ -778,7 +775,7 @@
// internal only, use removeClass("class")
remove: function( elem, classNames ) {
if (elem.nodeType == 1)
- elem.className = classNames != undefined ?
+ elem.className = classNames !== undefined ?
jQuery.grep(elem.className.split(/\s+/), function(className){
return !jQuery.className.has( classNames, className );
}).join(" ") :
@@ -946,19 +943,20 @@
clean: function( elems, context ) {
var ret = [];
context = context || document;
+
// !context.createElement fails in IE with an error but returns typeof 'object'
- if (typeof context.createElement == 'undefined')
+ if ( context.createElement === undefined )
context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
jQuery.each(elems, function(i, elem){
- if ( typeof elem == 'number' )
+ if ( typeof elem === "number" )
elem += '';
if ( !elem )
return;
// Convert html string into DOM nodes
- if ( typeof elem == "string" ) {
+ if ( typeof elem === "string" ) {
// Fix "XHTML"-style tags in all browsers
elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){
return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ?
@@ -1031,7 +1029,7 @@
if ( elem.length === 0 && (!jQuery.nodeName( elem, "form" ) && !jQuery.nodeName( elem, "select" )) )
return;
- if ( elem[0] == undefined || jQuery.nodeName( elem, "form" ) || elem.options )
+ if ( elem[0] === undefined || jQuery.nodeName( elem, "form" ) || elem.options )
ret.push( elem );
else
@@ -1139,7 +1137,7 @@
if( array != null ){
var i = array.length;
// The window, strings (and functions) also have 'length'
- if( i == null || typeof array == 'string' || jQuery.isFunction(array) || array.setInterval )
+ if( i == null || typeof array === "string" || jQuery.isFunction(array) || array.setInterval )
ret[0] = array;
else
while( i )
@@ -1364,12 +1362,12 @@
) :
// Get or set width or height on the element
- size == undefined ?
+ size === undefined ?
// Get width or height on the element
(this.length ? jQuery.css( this[0], type ) : null) :
// Set the width or height on the element (default to pixels if value is unitless)
- this.css( type, size.constructor == String ? size : size + "px" );
+ this.css( type, typeof size === "string" ? size : size + "px" );
};
});
Index: src/fx.js
===================================================================
--- src/fx.js (revision 5946)
+++ src/fx.js (working copy)
@@ -117,7 +117,7 @@
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.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
Index: src/selector.js
===================================================================
--- src/selector.js (revision 5946)
+++ src/selector.js (working copy)
@@ -92,7 +92,7 @@
find: function( t, context ) {
// Quickly handle non-string expressions
- if ( typeof t != "string" )
+ if ( typeof t !== "string" )
return [ t ];
// check to make sure context is a DOM element or a document
@@ -214,7 +214,7 @@
// Do a quick check for the existence of the actual ID attribute
// to avoid selecting by the name attribute in IE
// also check to insure id is a string to avoid selecting an element with the name of 'id' inside a form
- if ( (jQuery.browser.msie||jQuery.browser.opera) && oid && typeof oid.id == "string" && oid.id != m[2] )
+ if ( (jQuery.browser.msie||jQuery.browser.opera) && oid && typeof oid.id === "string" && oid.id != m[2] )
oid = jQuery('[@id="'+m[2]+'"]', elem)[0];
// Do a quick check for node name (where applicable) so
@@ -391,10 +391,10 @@
// Otherwise, find the expression to execute
} else {
var fn = jQuery.expr[ m[1] ];
- if ( typeof fn == "object" )
+ if ( typeof fn === "object" )
fn = fn[ m[2] ];
- if ( typeof fn == "string" )
+ if ( typeof fn === "string" )
fn = eval("false||function(a,i){return " + fn + ";}");
// Execute it against the current filter
Index: src/event.js
===================================================================
--- src/event.js (revision 5946)
+++ src/event.js (working copy)
@@ -21,7 +21,7 @@
handler.guid = this.guid++;
// if data is passed, bind to handler
- if( data != undefined ) {
+ if ( data !== undefined ) {
// Create temporary function pointer to original handler
var fn = handler;
@@ -40,7 +40,7 @@
handle = jQuery.data(elem, "handle") || jQuery.data(elem, "handle", function(){
// Handle the second event of a trigger and when
// an event is called after a page has unloaded
- if ( typeof jQuery != "undefined" && !jQuery.event.triggered )
+ if ( typeof jQuery !== "undefined" && !jQuery.event.triggered )
return jQuery.event.handle.apply(arguments.callee.elem, arguments);
});
// Add elem as a property of the handle function
@@ -99,7 +99,7 @@
if ( events ) {
// Unbind all events for the element
- if ( types == undefined || (typeof types == "string" && types.charAt(0) == ".") )
+ if ( types === undefined || (typeof types === "string" && types.charAt(0) == ".") )
for ( var type in events )
this.remove( elem, type + (types || "") );
else {
@@ -219,7 +219,7 @@
// call the extra function and tack the current return value on the end for possible inspection
ret = extra.apply( elem, val == null ? data : data.concat( val ) );
// if anything is returned, give it precedence and have it overwrite the previous value
- if (ret !== undefined)
+ if ( ret !== undefined )
val = ret;
}
Index: src/ajax.js
===================================================================
--- src/ajax.js (revision 5946)
+++ src/ajax.js (working copy)
@@ -3,7 +3,7 @@
_load: jQuery.fn.load,
load: function( url, params, callback ) {
- if ( typeof url != 'string' )
+ if ( typeof url !== "string" )
return this._load( url );
var off = url.indexOf(" ");
@@ -24,7 +24,7 @@
params = null;
// Otherwise, build a param string
- } else if( typeof params == 'object' ) {
+ } else if( typeof params === "object" ) {
params = jQuery.param( params );
type = "POST";
}
@@ -178,7 +178,7 @@
type = s.type.toUpperCase();
// convert data if not already a string
- if ( s.data && s.processData && typeof s.data != "string" )
+ if ( s.data && s.processData && typeof s.data !== "string" )
s.data = jQuery.param(s.data);
// Handle JSONP Parameter Callbacks
@@ -459,7 +459,7 @@
// IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
return !xhr.status && location.protocol == "file:" ||
( xhr.status >= 200 && xhr.status < 300 ) || xhr.status == 304 || xhr.status == 1223 ||
- jQuery.browser.safari && xhr.status == undefined;
+ jQuery.browser.safari && xhr.status === undefined;
} catch(e){}
return false;
},
@@ -471,7 +471,7 @@
// Firefox always returns 200. check Last-Modified date
return xhr.status == 304 || xhrRes == jQuery.lastModified[url] ||
- jQuery.browser.safari && xhr.status == undefined;
+ jQuery.browser.safari && xhr.status === undefined;
} catch(e){}
return false;
},
@@ -490,7 +490,7 @@
data = s.dataFilter( data, type );
// The filter can actually parse the response
- if( typeof data == 'string' ){
+ if( typeof data === "string" ){
// If the type is "script", eval it in global context
if ( type == "script" )
Download in other formats:
Original Format
File 3618.2.diff, 14.2 KB (added by john, November 17, 2008 04:19PM UTC)
All primitives are checked with typeof, undefined is checked with === undefined, objects are checked with isFunction or isArray, object checks use Object.prototype.toString.
Index: src/offset.js
===================================================================
--- src/offset.js (revision 5946)
+++ src/offset.js (working copy)
@@ -133,7 +133,7 @@
jQuery.fn[ method ] = function(val) {
if (!this[0]) return;
- return val != undefined ?
+ return val !== undefined ?
// Set the scroll offset
this.each(function() {
Index: src/core.js
===================================================================
--- src/core.js (revision 5946)
+++ src/core.js (working copy)
@@ -41,7 +41,7 @@
return this;
}
// Handle HTML strings
- if ( typeof selector == "string" ) {
+ if ( typeof selector === "string" ) {
// Are we dealing with HTML string or an ID?
var match = quickExpr.exec( selector );
@@ -93,7 +93,7 @@
// Get the Nth element in the matched element set OR
// Get the whole matched element set as a clean array
get: function( num ) {
- return num == undefined ?
+ return num === undefined ?
// Return a 'clean' array
jQuery.makeArray( this ) :
@@ -150,7 +150,7 @@
var options = name;
// Look for the case where we're accessing a style value
- if ( name.constructor == String )
+ if ( typeof name === "string" )
if ( value === undefined )
return this[0] && jQuery[ type || "attr" ]( this[0], name );
@@ -180,7 +180,7 @@
},
text: function( text ) {
- if ( typeof text != "object" && text != null )
+ if ( typeof text !== "object" && text != null )
return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
var ret = "";
@@ -292,7 +292,7 @@
// removeData doesn't work here, IE removes it from the original as well
// this is primarily for IE but the data expando shouldn't be copied over in any browser
var clone = ret.find("*").andSelf().each(function(){
- if ( this[ expando ] != undefined )
+ if ( this[ expando ] !== undefined )
this[ expando ] = null;
});
@@ -323,7 +323,7 @@
},
not: function( selector ) {
- if ( selector.constructor == String )
+ if ( typeof selector === "string" )
// test special case where just one selector is passed in
if ( isSimple.test( selector ) )
return this.pushStack( jQuery.multiFilter( selector, this, true ) );
@@ -339,7 +339,7 @@
add: function( selector ) {
return this.pushStack( jQuery.unique( jQuery.merge(
this.get(),
- typeof selector == 'string' ?
+ typeof selector === "string" ?
jQuery( selector ) :
jQuery.makeArray( selector )
)));
@@ -354,7 +354,7 @@
},
val: function( value ) {
- if ( value == undefined ) {
+ if ( value === undefined ) {
var elem = this[0];
if ( elem ) {
@@ -400,7 +400,7 @@
return undefined;
}
- if( value.constructor == Number )
+ if ( typeof value === "number" )
value += '';
return this.each(function(){
@@ -428,7 +428,7 @@
},
html: function( value ) {
- return value == undefined ?
+ return value === undefined ?
(this[0] ?
this[0].innerHTML :
null) :
@@ -550,7 +550,7 @@
var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;
// Handle a deep copy situation
- if ( target.constructor == Boolean ) {
+ if ( typeof target === "boolean" ) {
deep = target;
target = arguments[1] || {};
// skip the boolean and the target
@@ -558,7 +558,7 @@
}
// Handle case when target is a string or something (possible in deep copy)
- if ( typeof target != "object" && typeof target != "function" )
+ if ( typeof target !== "object" && !jQuery.isFunction(target) )
target = {};
// extend jQuery itself if only one argument is passed
@@ -579,7 +579,7 @@
continue;
// Recurse if we're merging object values
- if ( deep && copy && typeof copy == "object" && !copy.nodeType )
+ if ( deep && copy && typeof copy === "object" && !copy.nodeType )
target[ name ] = jQuery.extend( deep,
// Never move original objects, clone them
src || ( copy.length != null ? [ ] : { } )
@@ -599,7 +599,8 @@
// exclude the following css properties to add px
exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
// cache defaultView
- defaultView = document.defaultView || {};
+ defaultView = document.defaultView || {},
+ toString = Object.prototype.toString;
jQuery.extend({
noConflict: function( deep ) {
@@ -611,19 +612,15 @@
return jQuery;
},
- // See test/unit/core.js for details concerning this function.
+ // See test/unit/core.js for details concerning isFunction.
// Since version 1.3, DOM methods and functions like alert
// aren't supported. They return false on IE (#2968).
-
- // Memory leaks appear in IE6 when applying instanceof
- // to the window, document or any other COM object (#3485)
- // http://ajaxian.com/archives/working-aroung-the-instanceof-memory-leak
- isFunction: function( fn ) {
- return !!fn && !!fn.hasOwnProperty && fn instanceof Function;
+ isFunction: function( obj ) {
+ return toString.call(obj) === "[object Function]";
},
-
- isArray: function( arr ){
- return !!arr && arr.constructor == Array;
+
+ isArray: function( obj ) {
+ return toString.call(obj) === "[object Array]";
},
// check if an element is in a (or is an) XML document
@@ -732,7 +729,7 @@
var name, i = 0, length = object.length;
if ( args ) {
- if ( length == undefined ) {
+ if ( length === undefined ) {
for ( name in object )
if ( callback.apply( object[ name ], args ) === false )
break;
@@ -743,7 +740,7 @@
// A special, fast, case for the most common use of each
} else {
- if ( length == undefined ) {
+ if ( length === undefined ) {
for ( name in object )
if ( callback.call( object[ name ], name, object[ name ] ) === false )
break;
@@ -761,7 +758,7 @@
value = value.call( elem, i );
// Handle passing in a number to a CSS property
- return value && value.constructor == Number && type == "curCSS" && !exclude.test( name ) ?
+ return typeof value === "number" && type == "curCSS" && !exclude.test( name ) ?
value + "px" :
value;
},
@@ -778,7 +775,7 @@
// internal only, use removeClass("class")
remove: function( elem, classNames ) {
if (elem.nodeType == 1)
- elem.className = classNames != undefined ?
+ elem.className = classNames !== undefined ?
jQuery.grep(elem.className.split(/\s+/), function(className){
return !jQuery.className.has( classNames, className );
}).join(" ") :
@@ -946,19 +943,20 @@
clean: function( elems, context ) {
var ret = [];
context = context || document;
+
// !context.createElement fails in IE with an error but returns typeof 'object'
- if (typeof context.createElement == 'undefined')
+ if ( context.createElement === undefined )
context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
jQuery.each(elems, function(i, elem){
- if ( typeof elem == 'number' )
+ if ( typeof elem === "number" )
elem += '';
if ( !elem )
return;
// Convert html string into DOM nodes
- if ( typeof elem == "string" ) {
+ if ( typeof elem === "string" ) {
// Fix "XHTML"-style tags in all browsers
elem = elem.replace(/(<(\w+)[^>]*?)\/>/g, function(all, front, tag){
return tag.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i) ?
@@ -1031,7 +1029,7 @@
if ( elem.length === 0 && (!jQuery.nodeName( elem, "form" ) && !jQuery.nodeName( elem, "select" )) )
return;
- if ( elem[0] == undefined || jQuery.nodeName( elem, "form" ) || elem.options )
+ if ( elem[0] === undefined || jQuery.nodeName( elem, "form" ) || elem.options )
ret.push( elem );
else
@@ -1139,7 +1137,7 @@
if( array != null ){
var i = array.length;
// The window, strings (and functions) also have 'length'
- if( i == null || typeof array == 'string' || jQuery.isFunction(array) || array.setInterval )
+ if( i == null || typeof array === "string" || jQuery.isFunction(array) || array.setInterval )
ret[0] = array;
else
while( i )
@@ -1364,12 +1362,12 @@
) :
// Get or set width or height on the element
- size == undefined ?
+ size === undefined ?
// Get width or height on the element
(this.length ? jQuery.css( this[0], type ) : null) :
// Set the width or height on the element (default to pixels if value is unitless)
- this.css( type, size.constructor == String ? size : size + "px" );
+ this.css( type, typeof size === "string" ? size : size + "px" );
};
});
Index: src/fx.js
===================================================================
--- src/fx.js (revision 5946)
+++ src/fx.js (working copy)
@@ -117,7 +117,7 @@
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.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
Index: src/selector.js
===================================================================
--- src/selector.js (revision 5946)
+++ src/selector.js (working copy)
@@ -92,7 +92,7 @@
find: function( t, context ) {
// Quickly handle non-string expressions
- if ( typeof t != "string" )
+ if ( typeof t !== "string" )
return [ t ];
// check to make sure context is a DOM element or a document
@@ -214,7 +214,7 @@
// Do a quick check for the existence of the actual ID attribute
// to avoid selecting by the name attribute in IE
// also check to insure id is a string to avoid selecting an element with the name of 'id' inside a form
- if ( (jQuery.browser.msie||jQuery.browser.opera) && oid && typeof oid.id == "string" && oid.id != m[2] )
+ if ( (jQuery.browser.msie||jQuery.browser.opera) && oid && typeof oid.id === "string" && oid.id != m[2] )
oid = jQuery('[@id="'+m[2]+'"]', elem)[0];
// Do a quick check for node name (where applicable) so
@@ -391,10 +391,10 @@
// Otherwise, find the expression to execute
} else {
var fn = jQuery.expr[ m[1] ];
- if ( typeof fn == "object" )
+ if ( typeof fn === "object" )
fn = fn[ m[2] ];
- if ( typeof fn == "string" )
+ if ( typeof fn === "string" )
fn = eval("false||function(a,i){return " + fn + ";}");
// Execute it against the current filter
Index: src/event.js
===================================================================
--- src/event.js (revision 5946)
+++ src/event.js (working copy)
@@ -21,7 +21,7 @@
handler.guid = this.guid++;
// if data is passed, bind to handler
- if( data != undefined ) {
+ if ( data !== undefined ) {
// Create temporary function pointer to original handler
var fn = handler;
@@ -40,7 +40,7 @@
handle = jQuery.data(elem, "handle") || jQuery.data(elem, "handle", function(){
// Handle the second event of a trigger and when
// an event is called after a page has unloaded
- if ( typeof jQuery != "undefined" && !jQuery.event.triggered )
+ if ( typeof jQuery !== "undefined" && !jQuery.event.triggered )
return jQuery.event.handle.apply(arguments.callee.elem, arguments);
});
// Add elem as a property of the handle function
@@ -99,7 +99,7 @@
if ( events ) {
// Unbind all events for the element
- if ( types == undefined || (typeof types == "string" && types.charAt(0) == ".") )
+ if ( types === undefined || (typeof types === "string" && types.charAt(0) == ".") )
for ( var type in events )
this.remove( elem, type + (types || "") );
else {
@@ -219,7 +219,7 @@
// call the extra function and tack the current return value on the end for possible inspection
ret = extra.apply( elem, val == null ? data : data.concat( val ) );
// if anything is returned, give it precedence and have it overwrite the previous value
- if (ret !== undefined)
+ if ( ret !== undefined )
val = ret;
}
Index: src/ajax.js
===================================================================
--- src/ajax.js (revision 5946)
+++ src/ajax.js (working copy)
@@ -3,7 +3,7 @@
_load: jQuery.fn.load,
load: function( url, params, callback ) {
- if ( typeof url != 'string' )
+ if ( typeof url !== "string" )
return this._load( url );
var off = url.indexOf(" ");
@@ -24,7 +24,7 @@
params = null;
// Otherwise, build a param string
- } else if( typeof params == 'object' ) {
+ } else if( typeof params === "object" ) {
params = jQuery.param( params );
type = "POST";
}
@@ -178,7 +178,7 @@
type = s.type.toUpperCase();
// convert data if not already a string
- if ( s.data && s.processData && typeof s.data != "string" )
+ if ( s.data && s.processData && typeof s.data !== "string" )
s.data = jQuery.param(s.data);
// Handle JSONP Parameter Callbacks
@@ -459,7 +459,7 @@
// IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
return !xhr.status && location.protocol == "file:" ||
( xhr.status >= 200 && xhr.status < 300 ) || xhr.status == 304 || xhr.status == 1223 ||
- jQuery.browser.safari && xhr.status == undefined;
+ jQuery.browser.safari && xhr.status === undefined;
} catch(e){}
return false;
},
@@ -471,7 +471,7 @@
// Firefox always returns 200. check Last-Modified date
return xhr.status == 304 || xhrRes == jQuery.lastModified[url] ||
- jQuery.browser.safari && xhr.status == undefined;
+ jQuery.browser.safari && xhr.status === undefined;
} catch(e){}
return false;
},
@@ -490,7 +490,7 @@
data = s.dataFilter( data, type );
// The filter can actually parse the response
- if( typeof data == 'string' ){
+ if( typeof data === "string" ){
// If the type is "script", eval it in global context
if ( type == "script" )