Opened 14 years ago
Closed 13 years ago
#5303 closed bug (notabug)
An object that is supplied as an option value on instantiation will not end up on the instance (but a clone will)
Reported by: | timmolendijk | Owned by: | |
---|---|---|---|
Priority: | major | Milestone: | 1.8 |
Component: | ui.widget | Version: | 1.8rc3 |
Keywords: | object option value identity deep-copy clone | Cc: | |
Blocked by: | Blocking: |
Description
If you do:
var somedata = {x: 1}; $('#element').mywidget({data: somedata});
You would expect:
somedata === $('#element').mywidget('option', 'data')
Yet this is not the case!
I suspect this is caused by the deep-copy at jquery.ui.widget.js:57:
$[ namespace ][ name ].prototype = $.extend( true, basePrototype, { namespace: namespace, widgetName: name, widgetEventPrefix: $[ namespace ][ name ].prototype.widgetEventPrefix || name, widgetBaseClass: fullName }, prototype );
P.S. Line 57 is where this code occurs in 1.8rc1, but the problem applies to 1.8rc3 as well.
Change History (6)
comment:1 Changed 14 years ago by
comment:2 Changed 14 years ago by
On third thought I'm pretty sure the deep-copy at jquery.ui.widget.js:129 is causing this problem:
this.options = $.extend( true, {}, this.options, $.metadata && $.metadata.get( element )[ this.widgetName ], options );
comment:3 Changed 14 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
We don't claim anywhere that the options hash originally supplied would be the options hash that actually gets used. This is not a bug.
comment:4 Changed 14 years ago by
- I'm not talking about the options hash, I'm talking about the values of options.
- Wouldn't you agree that it is to be expected, or at least to be desired that if you supply an object x as the value of an option, this exact same object x ends up as the value of that option after instantiation?
comment:5 Changed 13 years ago by
Resolution: | invalid |
---|---|
Status: | closed → reopened |
See previous comment
comment:6 Changed 13 years ago by
Resolution: | → invalid |
---|---|
Status: | reopened → closed |
No. Deep copying is the intended behavior. Please do not re-open this ticket.
Note: See
TracTickets for help on using
tickets.
On second thought I think the cause is the deep-copy at jquery.ui.widget.js:73: