mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Widget: Handle Object.create(null)
for options objects
Fixes #15179 Closes gh-1809
This commit is contained in:
parent
ef2e9bab92
commit
b3c0a7f71d
@ -5,7 +5,7 @@ define( [
|
||||
], function( QUnit, $ ) {
|
||||
|
||||
QUnit.test( "$.widget.extend()", function( assert ) {
|
||||
assert.expect( 27 );
|
||||
assert.expect( 28 );
|
||||
|
||||
var ret, empty, optionsWithLength, optionsWithDate, myKlass, customObject, optionsWithCustomObject, nullUndef,
|
||||
target, recursive, obj, input, output,
|
||||
@ -108,6 +108,11 @@ QUnit.test( "$.widget.extend()", function( assert ) {
|
||||
assert.deepEqual( input, output, "don't clone arrays" );
|
||||
input.key[ 0 ] = 10;
|
||||
assert.deepEqual( input, output, "don't clone arrays" );
|
||||
|
||||
input = Object.create( null );
|
||||
input.foo = "f";
|
||||
output = $.widget.extend( {}, input );
|
||||
assert.deepEqual( input, output, "Object with no prototype" );
|
||||
} );
|
||||
|
||||
} );
|
||||
|
@ -26,6 +26,7 @@
|
||||
}( function( $ ) {
|
||||
|
||||
var widgetUuid = 0;
|
||||
var widgetHasOwnProperty = Array.prototype.hasOwnProperty;
|
||||
var widgetSlice = Array.prototype.slice;
|
||||
|
||||
$.cleanData = ( function( orig ) {
|
||||
@ -183,7 +184,7 @@ $.widget.extend = function( target ) {
|
||||
for ( ; inputIndex < inputLength; inputIndex++ ) {
|
||||
for ( key in input[ inputIndex ] ) {
|
||||
value = input[ inputIndex ][ key ];
|
||||
if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
|
||||
if ( widgetHasOwnProperty.call( input[ inputIndex ], key ) && value !== undefined ) {
|
||||
|
||||
// Clone objects
|
||||
if ( $.isPlainObject( value ) ) {
|
||||
|
Loading…
Reference in New Issue
Block a user