Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#7927 closed bug (notabug)

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);

Change History (3)

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

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.

comment:2 in reply to:  1 Changed 9 years ago by mrubio

Replying to 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.

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

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

Note: See TracTickets for help on using tickets.