Skip to main content

Search and Top Navigation

#7927 closed bug (notabug)

Opened December 01, 2011 10:29AM UTC

Closed December 01, 2011 01:16PM UTC

Last modified December 01, 2011 02:33PM UTC

Widget inherits super widget properties

Reported by: mrubio Owned by:
Priority: minor Milestone: 1.9.0
Component: ui.widget Version: 1.8.16
Keywords: Cc:
Blocked by: Blocking:
Description

If you make widget foo, and then widget bar which extends foo, the extended widget(foo) prototype will inherit its properties.

Precondition is the property must be an object, and must be empty on the base widget.

var meh = {
    foo:{},
    _create: function() { }
}
jQuery.widget('fd.meh',meh);

var moh = {
    foo:{bar:'bar'},
    _create: function() { }
}
jQuery.widget('fd.moh',jQuery.fd.meh,moh);

console.log(jQuery.fd.meh.prototype);
Attachments (0)
Change History (3)

Changed December 01, 2011 01:16PM UTC by scottgonzalez comment:1

resolution: → invalid
status: newclosed

That's just how inheritance works. You're not going to get the expected results even without inheritance if you have an object in your prototype because every instance will be sharing the same object.

Changed December 01, 2011 02:28PM UTC by mrubio comment:2

Replying to [comment:1 scott.gonzalez]:

That's just how inheritance works. You're not going to get the expected results even without inheritance if you have an object in your prototype because every instance will be sharing the same object.

I expected them to be copied like options property.

Changed December 01, 2011 02:33PM UTC by scottgonzalez comment:3

Well, that actually happens in master (1.9pre), but you're still going to have every instance sharing the same object.