Skip to main content

Search and Top Navigation

#9382 closed bug (notabug)

Opened June 19, 2013 03:36AM UTC

Closed June 19, 2013 02:48PM UTC

Widget array member property (non-option) shared between instances

Reported by: AMA3AMA3 Owned by:
Priority: minor Milestone: none
Component: ui.widget Version: 1.10.3
Keywords: Cc:
Blocked by: Blocking:
Description

When a widget is defined having an array as a (non-option) member, the member is shared between instances. When defined as null and then assigned to an array in _create, each instance gets its own.

http://jsfiddle.net/u4ar3/

Happens w/jQUI 1.10.3 in IE10, FF21, Chrome 27 and Opera 12.15. Also happens in the jsfiddle using jQUI 1.9.2.

This is somewhat similar to #8645 but does not involve options; therefore, I believe that this issue should be treated differently.

Attachments (0)
Change History (1)

Changed June 19, 2013 02:48PM UTC by tj.vantoll comment:1

resolution: → notabug
status: newclosed

The object you pass as the last argument to

$.widget
is an object to be used as the prototype of the widget, which, by definition means that it will be shared across all instances. If you want an array that is instance specific you should only define it in
_create()
and avoid setting any arrays on the prototype.

$.widget( "foo.bar", {
    _create: function() {
        this._array = [];
    }
});