Opened 12 years ago

Closed 12 years ago

#2448 closed defect (wontfix)

dojo.lang.forEach issue with Select nodes

Reported by: r.j.coon@… Owned by: alex
Priority: high Milestone: 0.9
Component: Core Version: 0.4.1
Keywords: Cc:
Blocked By: Blocking:


If dojo.lang.forEach is passed an HTML Select node as its first argument, it will execute the function in the second argument on each Option node within the Select node only in browsers that do not support the Array.forEach method (i.e., IE6).

This issue is the root cause of bug #2354.

Change History (4)

comment:1 Changed 12 years ago by bill

Component: GeneralCore
Milestone: 0.9
Owner: changed from anonymous to alex

I assume we aren't fixing this. forEach's first argument is supposed to be an Array. If you (or the lfx code) are passing in a Select node then you are doing something wrong. Right Alex?

comment:2 Changed 12 years ago by guest

While I can understand this decision, it is not consistent with the code within dojo 0.4x. dojo.lfx.html._byId() checks the argument with isArrayLike(), not isArray(), to determine whether to use forEach() or not.

Further, it seems like a better idea to behave identically across browsers rather than to "work" in one and not the other.

If it is decided that this is not a bug with forEach(), the fact that the first argument must be an Array and not simply "look" like one should be clearly documented.

comment:3 Changed 12 years ago by bill

OK, I guess I'm not sure what this bug is asking for. Maybe it's already "fixed"? In 0.9, the behavior of dojo.forEach() is consistent across all browsers. dojo.forEach(<select>) won't work on any browser now, AFAICT. And I don't see isArrayLike() in the fx code in 0.9. Are you seeing something different? The documentation is also pretty clear, that dojo.forEach() only takes an array:

forEach: function(/*Array*/arr, /*Function*/callback, /*Object?*/obj){
	// summary:
	//		for every item in arr, call callback with that item as its
	//		only parameter.
	// description:
	//		Return values are ignored. This function
	//		corresponds (and wraps) the JavaScript 1.6 forEach method. For
	//		more details, see:

comment:4 Changed 12 years ago by bill

Resolution: wontfix
Status: newclosed

Talked to Alex about this. We're conflicted, but basically you are passing an illegal (non-array) argument to forEach(), so the results are undefined.

Note: See TracTickets for help on using tickets.