Opened 16 years ago

Closed 16 years ago

Last modified 15 years ago

#661 closed defect (invalid)

Dictionary.getKeySet() fails when dictionary has only 1 item

Reported by: [email protected] Owned by: Tom Trenka
Priority: high Milestone:
Component: General Version: 0.2
Keywords: Cc:
Blocked By: Blocking:


This is an off by one in either the DictionaryIterator? or the Dictionary.getKeySet() function. I'd say its a problem with DictionaryIterator?. This class initializes as follows:

var arr = [] ; Create an indexing array for (var p in obj) arr.push(obj[p]) ; fill it up var position = 0 ; this.atEnd = (position>=arr.length-1);

That means this.atEnd is true when arr.length == 1. And it means that a typical iterator loop (e.g. the one found in Dictionary.getKeySet) fails when arr.length == 1.

this.getKeyList = function(){

var arr = []; var e = this.getIterator(); while (!e.atEnd) {

arr.push(e.key); e.moveNext();

} return arr;


dojo.collections.Iterator has the same problem.

Change History (3)

comment:1 Changed 16 years ago by alex

Milestone: 0.3release
Owner: changed from anonymous to Tom Trenka

comment:2 Changed 16 years ago by Tom Trenka

Resolution: invalid
Status: newclosed

This bug must be against 0.2.2; it's already been fixed in the HEAD with the revision of the Iterator classes (current [dictionary].getKeyList uses for the results).

comment:3 Changed 15 years ago by (none)

Milestone: 0.3release

Milestone 0.3release deleted

Note: See TracTickets for help on using tickets.