Skip to main content

Bug Tracker

Side navigation

Ticket #5704: extendcorrection.txt
File extendcorrection.txt, 0.9 KB (added by kbwood, December 23, 2009 06:01AM UTC)

$.extend correction

jQuery.extend = jQuery.fn.extend = function() {
	...
	for ( ; i < length; i++ )
		// Only deal with non-null/undefined values
		if ( (options = arguments[ i ]) != null )
			// Extend the base object
			for ( var name in options ) {
				var src = target[ name ], copy = options[ name ];

				// Prevent never-ending loop
				if ( target === copy )
					continue;

				// Recurse if we're merging object values
				if ( deep && copy && typeof copy === "object" && !copy.nodeType )
					target[ name ] = jQuery.extend( deep, 
						// Never move original objects, clone them
						(typeof src === "object" ? src : null) || ( copy.length != null ? [ ] : { } ) //***Changed***
					, copy );

				// Don't bring in undefined values
				else if ( copy !== undefined )
					target[ name ] = copy;

			}

	// Return the modified object
	return target;
};

Download in other formats:

Original Format