for ( ; inputIndex < inputLength; inputIndex++ ) {
for ( key in input[ inputIndex ] ) {
value = input[ inputIndex ][ key ];
- if (input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
- if ( $.isPlainObject( value ) && $.isPlainObject( target[ key ] ) ) {
- target[ key ] = $.widget.extend( {}, target[ key ], value );
+ if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
+ // Clone objects
+ if ( $.isPlainObject( value ) ) {
+ target[ key ] = $.isPlainObject( target[ key ] ) ?
+ $.widget.extend( {}, target[ key ], value ) :
+ // Don't extend strings, arrays, etc. with objects
+ $.widget.extend( {}, value );
+ // Copy everything else by reference
} else {
target[ key ] = value;
}