Ticket #4122 (new defect)

Opened 16 months ago

Last modified 9 months ago

dijit.WidgetSet methods broken or mis-designed

Reported by: alex Owned by: alex
Priority: normal Milestone: 2.0
Component: Dijit Version: 0.9
Severity: normal Keywords: 4alex
Cc: alex

Description

the methods on dijit.WidgetSet? (and by association, dijit.registry) appear to surface array-like semantics (forEach, filter, etc.), however these methods do not take a scope parameter and do not return an array-like object. Given that many other bread-and-butter Dojo interfaces respect array-like semantics (sometimes going to great length to do so), these methods should probably be re-designed and a toArray() method (or better, basic array behavior on the base class itself) should be added to the class.

Change History

Changed 16 months ago by bill

  • owner changed from bill to alex

For efficiency reasons WidgetSet? holds a hash rather than an array, since the widgets are typically accessed by id.

toArray() method was left out on purpose, to prevent users from doing something inefficient like dojo.filter(widgetSet.toArray(), ...) rather than widgetSet.filter(..).

I guess the return value from byClass() or filter() could be an array, although I want to do things like

dijit.byClass("Button").forEach(...)

which means that we need to return a souped-up array like NodeList? does, not a plain []. There should probably be support for that in dojo.

Talked to Alex about this. He said he'll make a backwards-compatible patch to support stuff like this and then (if it looks OK) I'll add to 1.0.

Changed 16 months ago by bill

PS: oh Alex said that he wants a toArray() function for debugging output. I don't mind adding it for that reason but let's name it _dumpToArray() to make it clear that people shouldn't be using it in general.

Changed 15 months ago by bill

  • keywords 4alex added

Changed 9 months ago by bill

  • milestone changed from 1.1 to 2.0

Too late to make an API change (or even addition) for Dijit 1.1... bumping.

Note: See TracTickets for help on using tickets.