#903 closed defect (worksforme)
Array object incompatibility with Prototype 1.5.0 rc0
Reported by: | jwang | Owned by: | alex |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | General | Version: | 0.3 |
Keywords: | prototype | Cc: | |
Blocked By: | Blocking: |
Description
When running Dojo 0.3.0 AJAX edition with prototype.js 1.5.0 rc0 loaded first, a dojo.io.bind call will produce the following error in Firefox's JavaScript? Console:
Error:
mll[x] is not a function
http://foo.bar/dojo/dojo.js Line: 212
This error is observed using Firefox 1.5.0.4 and 1.0.7, both on Linux.
Attachments (1)
Change History (8)
comment:1 Changed 15 years ago by
Version: | 0.2 → 0.3 |
---|
comment:2 Changed 15 years ago by
comment:3 Changed 15 years ago by
comment:4 Changed 15 years ago by
I can see sjmiles' point. I just want to know what dojo's position is on this. Can/will dojo accomodate this or does the fix need to happen on the prototype side? I'd like the ability to use them together.
comment:5 Changed 15 years ago by
Milestone: | → 0.3.1 |
---|---|
Owner: | changed from anonymous to alex |
Talked to Alex on IRC: he wants to look at this one for 0.3.1.
comment:6 Changed 15 years ago by
Resolution: | → worksforme |
---|---|
Status: | new → closed |
ok, I've investigated, and in both 0.3.0 and in trunk, the offending line is using good-old for(var x=0; x<blah.length; x++) iteration. There is no test page attached to this bug or linked from the referenced mailing list post, and mixing Prototype 1.5.0rc0 into a page that includes both bare-bones Dojo and Dojo with widgets does not elicit an exception of any kind. I tested both Dojo from source and from builds.
What's more concerning to me is this seemingly incorrect understanding of the folks on the Prototype list regarding the way things "should" be done in JavaScript?. That they are not coding defensively shows in the content of their post. It's tone may be defensive but the code sure isn't. Scott is entirely correct about efficient iteration, which the following code snippet from a command-line Spidermonkey session demonstrates:
js> bar = new Array(1000); ,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, js> bar[5] = "blah"; blah js> bar[500] = "thud"; thud js> var inc = 0; js> for(var x in bar){ print(inc++); print(x+": "+bar[x]); } 0 5: blah 1 500: thud js>
In closing, I can't reproduce the bug and the person you're conversing with on the rails-spinoffs list doesn't know what they're talking about. If Dojo is indeed broken with Prototype, I'd love to see a test page. I'm attaching the one I used to verify the non-issue.
Marking "worksforme"
Regards
Changed 15 years ago by
Attachment: | test_coexistance.html added |
---|
comment:7 Changed 15 years ago by
Milestone: | 0.3.1 |
---|
Sorry, I got the causality wrong :( The error is generated by dojo.addOnLoad and not prototype.js. On #dojo, I've heard addOnLoad broke during the refactor and was fixed post 0.3.0. Sorry for the misdiagnosis.
I posted this issue on the rails-spinoffs list and got the following response:
http://wrath.rubyonrails.org/pipermail/rails-spinoffs/2006-June/004298.html
Here's a quote from the reply. The reply also includes some example JS not quoted below.