_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(" ");
params = null;
// Otherwise, build a param string
- } else if( typeof params == 'object' ) {
+ } else if( typeof params === "object" ) {
params = jQuery.param( params );
type = "POST";
}
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
// 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;
},
// 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;
},
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" )
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 );
// 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 ) :
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 );
},
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 = "";
// 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;
});
},
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 ) );
add: function( selector ) {
return this.pushStack( jQuery.unique( jQuery.merge(
this.get(),
- typeof selector == 'string' ?
+ typeof selector === "string" ?
jQuery( selector ) :
jQuery.makeArray( selector )
)));
},
val: function( value ) {
- if ( value == undefined ) {
+ if ( value === undefined ) {
var elem = this[0];
if ( elem ) {
return undefined;
}
- if( value.constructor == Number )
+ if ( typeof value === "number" )
value += '';
return this.each(function(){
},
html: function( value ) {
- return value == undefined ?
+ return value === undefined ?
(this[0] ?
this[0].innerHTML :
null) :
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
}
// 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
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 ? [ ] : { } )
// 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 ) {
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
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;
// 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;
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;
},
// 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(" ") :
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) ?
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
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 )
) :
// 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" );
};
});