Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#5004 closed defect (fixed)

QueryReadStore and Proto*cough* incompatible [patch] [cla]

Reported by: guest Owned by: Jared Jurkiewicz
Priority: high Milestone: 1.0.1
Component: DojoX Data Version: 0.9
Keywords: prototye queryreadstore Cc:
Blocked By: Blocking:

Description

The way the data.items is iterated through in QueryReadStore? throws an exception if Prototype 1.5 is loaded side-by-side because of the methods that Prototype adds to Array.prototype. While I can't justify use of prototype, in the real-world it happens and so compatibility should be strived for. The attached patch will iterate over the array using dojo.forEach which appropriately deals with the case.

CLA on file

dojo@…

Attachments (2)

qrs.diff (709 bytes) - added by guest 12 years ago.
query read store works with prototype if you replace for(i ... array ... ) with dojo.forEach
dojox.data.XmlStore_QueryStore_20071113.patch (3.1 KB) - added by Jared Jurkiewicz 12 years ago.
Updated patch for QueryReadStore? and XmlStore? + a fix for another bug found in the QueryReadStore?.html file

Download all attachments as: .zip

Change History (10)

Changed 12 years ago by guest

Attachment: qrs.diff added

query read store works with prototype if you replace for(i ... array ... ) with dojo.forEach

comment:1 Changed 12 years ago by Adam Peller

Milestone: 1.01.0.1

you should be able to pass 'this' in to dojo.forEach as an additional arg and avoid the qme decl

comment:2 Changed 12 years ago by guest

quite

comment:3 Changed 12 years ago by Jared Jurkiewicz

Thanks. I'll look at getting this in for 1.0.1

comment:4 Changed 12 years ago by dante

fwiw you can probably just

dojo.forEach(data.items,function(e){ 
    this._items.push({i:e, r:this}); 
},this); 

comment:5 Changed 12 years ago by guest

to test this thing you can try to extend Array.prototype. the dojo.forEach knows not to use array.length (which counts the funny functions that get added to the prototype) to iterate through the array members.

The exception you get when you extend Array.prototype is some sort of complaint about identifier defined but not a part of such-and-such an item (the function that extends Array.prototype, it turns out).

So the test case is to include the other javascript library (or manually extend Array.prototype) and then load a dataset with the identifier (from {identifier: id, items:[{...},...]}) specified into a combobox or unit test suite.

comment:6 Changed 12 years ago by Jared Jurkiewicz

XmlStore? is also broken on this, by the by. I just fixed it too, using similar fixes. Will be generating a patch shortly.

Changed 12 years ago by Jared Jurkiewicz

Updated patch for QueryReadStore? and XmlStore? + a fix for another bug found in the QueryReadStore?.html file

comment:7 Changed 12 years ago by Jared Jurkiewicz

Resolution: fixed
Status: newclosed

(In [11507]) Fixes for prototype compatibility. Also fixed another bug in the simple QueryReadStore?.html test file. fixes #5004

comment:8 Changed 12 years ago by Jared Jurkiewicz

(In [11508]) Carrying fix forward. refs #5004

Note: See TracTickets for help on using tickets.