Opened 16 years ago
Closed 16 years ago
#533 closed defect (duplicate)
dojo.collections.DictionaryIterator doesn't support iteration over one item
Reported by: | Owned by: | anonymous | |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | General | Version: | 0.2 |
Keywords: | iterator | Cc: | |
Blocked By: | Blocking: |
Description
Reproduce the bug with the following code snippet:
//Create a dictionary with one item var aDictionary = new dojo.collections.Dictionary(); aDictionary.add("singleItem",anItem); //Iterate it with a "atEnd" while loop var iterator = aDictionary.getIterator(); while (!iterator.atEnd ) { alert(iterator.key); iterator.moveNext(); }
The alert statement will not be executed because atEnd is incorrectly initialized in DictionaryIterator?. Line 47 of Collections.js,
this.atEnd = (position>=arr.length-1);
should be replaced with
this.atEnd = (position>=arr.length);
in order to support while loops using atEnd
Note: See
TracTickets for help on using
tickets.