Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#10587 closed bug (notabug)

$.widget() breaks class instances passed in widget prototype

Reported by: Victor Homyakov Owned by:
Priority: minor Milestone: none
Component: ui.widget Version: 1.11.1
Keywords: Cc:
Blocked by: Blocking:

Description

Updates of jQuery and jQuery UI broke the following widget code: http://jsfiddle.net/fyox1r56/2/ - works in jQuery 1.9.1 + jQuery 1.9.2 http://jsfiddle.net/fyox1r56/3/ - throws in jQuery 2.0.2 + jQuery 1.10.3

Now when widget prototype contains an object, it is cloned no matter when it's a plain object or an instance of some class with some code in its prototype chain.

This is because $.widget relies on isPlainObject functionality which was recently substantially changed in jQuery.

Change History (3)

comment:1 Changed 7 years ago by Scott González

Resolution: notabug
Status: newclosed

This is not intended to work.

comment:2 Changed 7 years ago by Victor Homyakov

Nowhere in the documentation for $.widget (http://api.jqueryui.com/jQuery.widget/) was stated that not only widget's prototype, but also each and every of prototype's properties should be plain object (http://api.jquery.com/Types/#PlainObject).

Also, nowhere is stated that prototype's properties not satisfying $.isPlainObject() are shallow cloned.

comment:3 Changed 7 years ago by Scott González

This is just how prototypes work in JavaScript.

Note: See TracTickets for help on using tickets.