Opened 21 months ago

Closed 21 months ago

Last modified 21 months ago

#15179 closed bug (fixed)

Widget can't be initialized with an option object that has no hasOwnProperty function

Reported by: Christoph Obexer Owned by: Scott González
Priority: minor Milestone: 1.12.2
Component: ui.widget Version: 1.12.1
Keywords: Cc:
Blocked by: Blocking:

Description

Initializing any widget like:

var options = Object.create(null);
options.label = 'Button Label';
$('#button').button(options);

throws an error like:

input[inputIndex].hasOwnProperty is not a function

Runnable example: http://jsbin.com/juneboqere/edit?html,js,output Responsible code: https://github.com/jquery/jquery-ui/blob/ef2e9bab92ae898311baa295590cd487d9071319/ui/widget.js#L186

jQuery UI must not rely on hasOwnProperty of passed objects, but must instead use Object.prototype.hasOwnProperty to avoid this problem.

jQuery's own extend doesn't have this problem and the code below works:

var options = Object.create(null);
options.label = 'Button Label';
$('#button').button($.extend({}, options));

Change History (4)

comment:1 Changed 21 months ago by Scott González

Component: ui.coreui.widget
Status: newopen

comment:3 Changed 21 months ago by Scott González

Owner: set to Scott González
Resolution: fixed
Status: openclosed

In b3c0a7f:

Widget: Handle Object.create(null) for options objects

Fixes #15179
Closes gh-1809

comment:4 Changed 21 months ago by Scott González

Milestone: none1.12.2
Note: See TracTickets for help on using tickets.