Skip to main content

Search and Top Navigation

#15179 closed bug (fixed)

Opened April 21, 2017 04:22PM UTC

Closed April 24, 2017 04:41PM UTC

Last modified April 24, 2017 04:42PM UTC

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

Reported by: cobexer Owned by: scottgonzalez
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));
Attachments (0)
Change History (4)

Changed April 21, 2017 06:50PM UTC by scottgonzalez comment:1

component: ui.coreui.widget
status: newopen

Changed April 21, 2017 06:51PM UTC by scottgonzalez comment:2

Changed April 24, 2017 04:41PM UTC by scottgonzalez comment:3

owner: → scottgonzalez
resolution: → fixed
status: openclosed

In [changeset:"b3c0a7f71d0b351755b97858ad47de4e9a373606" b3c0a7f]:

#!CommitTicketReference repository="" revision="b3c0a7f71d0b351755b97858ad47de4e9a373606"
Widget: Handle  for options objects

Fixes #15179
Closes gh-1809

Changed April 24, 2017 04:42PM UTC by scottgonzalez comment:4

milestone: none1.12.2