Opened 10 years ago

Closed 8 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)

operaEvent.html (730 bytes) - added by bill 10 years ago.
works fine for me, put this file parallel to dojo/ and dijit/ directories
operaEvent_prototype.html (799 bytes) - added by Sami 10 years ago.
reproducing sparse array byusing both dojo and prototype.js on same page

Download all attachments as: .zip

Change History (18)

comment:1 Changed 10 years ago by bill

Component: GeneralEvents
Owner: changed from anonymous to sjmiles

Same as #10010?

comment:2 Changed 10 years ago by Utz-Uwe Haus

Seems very much so.

comment:3 Changed 10 years ago by bill

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 10 years ago by bill

Attachment: operaEvent.html added

works fine for me, put this file parallel to dojo/ and dijit/ directories

comment:4 Changed 10 years ago by dante

Milestone: tbdfuture
severity: majornormal

comment:5 Changed 10 years ago by Sami

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 10 years ago by Sami

Attachment: operaEvent_prototype.html added

reproducing sparse array byusing both dojo and prototype.js on same page

comment:6 Changed 10 years ago by Utz-Uwe Haus

I can confirm that my initial report was from a scenario using prototype.js and dojo on the same page too.

comment:7 Changed 10 years ago by Eugene Lazutkin

Cc: Eugene Lazutkin added
Keywords: prototype added

comment:8 Changed 10 years ago by bill

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 9 years ago by cweiske

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 9 years ago by bill

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 8 years ago by hallvord@…

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 8 years ago by bill

Owner: changed from sjmiles to Kris Zyp

comment:13 Changed 8 years ago by hallvord@…

(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 8 years ago by Kris Zyp

So this is a Prototype bug? I assume we can mark this bug as invalid then.

comment:15 Changed 8 years ago by hallvord@…

yes to both questions :)

comment:16 Changed 8 years ago by Kris Zyp

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.