mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
Widget: Fixed $.widget.extend() to never copy objects by reference.
This commit is contained in:
parent
d535f6869f
commit
5e0a2ca1e5
9
ui/jquery.ui.widget.js
vendored
9
ui/jquery.ui.widget.js
vendored
@ -143,8 +143,13 @@ $.widget.extend = function( target ) {
|
||||
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 );
|
||||
// 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user