Search and Top Navigation
#5303 closed bug (notabug)
Opened March 07, 2010 06:38PM UTC
Closed October 12, 2010 02:22AM UTC
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.
Attachments (0)
Change History (6)
Changed March 07, 2010 06:41PM UTC by comment:1
Changed March 07, 2010 06:47PM UTC by comment:2
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 );
Changed March 08, 2010 01:29AM UTC by comment:3
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.
Changed March 12, 2010 12:15AM UTC by comment:4
1. I'm not talking about the options hash, I'm talking about the values of options.
2. 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?
Changed October 12, 2010 02:10AM UTC by comment:5
resolution: | invalid |
---|---|
status: | closed → reopened |
See previous comment
Changed October 12, 2010 02:22AM UTC by comment:6
resolution: | → invalid |
---|---|
status: | reopened → closed |
No. Deep copying is the intended behavior. Please do not re-open this ticket.
On second thought I think the cause is the deep-copy at jquery.ui.widget.js:73: