Opened 11 years ago
Closed 10 years ago
#9983 closed defect (invalid)
sparse array trick fails on Opera 10
Reported by: | Utz-Uwe Haus | Owned by: | Kris Zyp |
---|---|---|---|
Priority: | high | Milestone: | future |
Component: | Events | Version: | 1.3.2 |
Keywords: | prototype | Cc: | Eugene Lazutkin |
Blocked By: | Blocking: |
Description
Opera 10 (haven't checked older versions) un-sparsifies sparse arrays on copying to have `undefined' entries in the previously unused slots. This breaks the code generated by dojo._listener.getDispatcher(). For me changing the
if(!dojo.isRhino)
to
if(!dojo.isRhino && !dojo.isOpera)
fixes the problem. Apparently the surrounding includeStart-magic should be updated too.
Unfortunately I have no small test case to attach; actually I have no clear idea how to trigger the situation that the handler array becomes sparse. However, try [].concat(ls) on a sparse `ls' exhibits the problem.
This is similar to the Rhino special casing done in #7523.
Attachments (2)
Change History (18)
comment:1 Changed 11 years ago by
Component: | General → Events |
---|---|
Owner: | changed from anonymous to sjmiles |
comment:3 Changed 11 years ago by
The issue is apparently with setting up multiple handlers on a *plain function*, as opposed to handlers for DOM events like onclick. And the sparse array issue apparently comes from disconnecting a handler.
The code as-is is working fine for me on Opera10/mac and Opera10/windows. I'll attach my test case. I'm not seeing gaps in the array.
My opera is:
Version 10.00 Build 6652
Changed 11 years ago by
Attachment: | operaEvent.html added |
---|
works fine for me, put this file parallel to dojo/ and dijit/ directories
comment:4 Changed 11 years ago by
Milestone: | tbd → future |
---|---|
severity: | major → normal |
comment:5 Changed 11 years ago by
Could reproduce the issue while trying to use both dojo and prototype.js on the same page. When prototype.js is included into bill's testpage the array becomes sparse and opera 10 throws an error (see attachment).
Changed 11 years ago by
Attachment: | operaEvent_prototype.html added |
---|
reproducing sparse array byusing both dojo and prototype.js on same page
comment:6 Changed 11 years ago by
I can confirm that my initial report was from a scenario using prototype.js and dojo on the same page too.
comment:7 Changed 11 years ago by
Cc: | Eugene Lazutkin added |
---|---|
Keywords: | prototype added |
comment:8 Changed 11 years ago by
OK, I see it too, with prototype 1.6.1.
Maybe we should just make the rhino path the default, getting rid of the current default path.
comment:9 Changed 10 years ago by
I see this bug in Opera 11.00 when using Tiny Tiny RSS (http://tt-rss.org/redmine/issues/291), so it is still relevant at least for me. Any fix in sight?
comment:10 Changed 10 years ago by
Note: the rhino code was removed in [22570] and merged to trunk in [22989].
I tried sparse arrays on opera 10 with prototype loaded (from the page http://www.prototypejs.org/), they seem to work fine:
>>> var ary = ['a', 'b', 'c'];delete ary[1];var copy = [].concat(ary); true >>> copy[1] undefined
On opera11 it also worked as expected for me, from the address bar:
javascript:var ary = ['a', 'b', 'c'];delete ary[1];var copy = [].concat(ary); alert(copy[1]);
So requires some more investigation.
comment:11 Changed 10 years ago by
This is caused by a Prototype workaround against an earlier Opera bug/incompatibility.
As a result of this workaround, array.concat() doesn't work as expected on sparse arrays:
if (Prototype.Browser.Opera){ Array.prototype.concat = function() { var array = []; for (var i = 0, length = this.length; i < length; i++) array.push(this[i]); for (var i = 0, length = arguments.length; i < length; i++) { if (Object.isArray(arguments[i])) { for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++) array.push(arguments[i][j]); } else { array.push(arguments[i]); } } return array; }; }
See https://prototype.lighthouseapp.com/projects/8886/tickets/972-issue-regarding-arrayconcat
comment:12 Changed 10 years ago by
Owner: | changed from sjmiles to Kris Zyp |
---|
comment:13 Changed 10 years ago by
(BTW, I believe this bug is fixed in new Prototype.js versions, though I don't know exactly when the fix went out)
comment:14 Changed 10 years ago by
So this is a Prototype bug? I assume we can mark this bug as invalid then.
comment:16 Changed 10 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
Same as #10010?