doekman / base2

Automatically exported from code.google.com/p/base2
0 stars 0 forks source link

Implement traversal methods on the options arrays of select objects #79

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In Firefox at least, haven't tested in other browsers, an error is thrown
to the console when attempting to use forEach on the options array of a
select object.

In the context of the reduced test case attached that error is
"$select.options.forEach is not a function".

I don't know if it's even possible to implement the traversal methods on
the options array, especially given base2 probably isn't doing anything
with those particular methods on the Gecko platform, given they are
supported natively. But I think it would be a useful enhancement to
explore...  I'm spoilt by such conveniences!

By the way, tested using Firefox 3 Beta 5 on Mac OS X, 10.5.2, and the
latest base2 code from subversion.

Original issue reported on code.google.com by richy...@gmail.com on 3 Apr 2008 at 7:43

Attachments:

GoogleCodeExporter commented 9 years ago
base2 already provides methods for this. You can cast the options collection:

Enumerable(select.options);

Or you can use generic array methods to iterate the collection:

Array2.forEach(select.options, function(option) {
  // do something
});

Is that not good enough?

Original comment by dean.edw...@gmail.com on 3 Apr 2008 at 11:45

GoogleCodeExporter commented 9 years ago
This also works:

forEach(select.options, function(option) {
  // do something
});

Original comment by dean.edw...@gmail.com on 3 Apr 2008 at 11:46

GoogleCodeExporter commented 9 years ago
I guess since I was binding globally already, I wanted it to just be there.

I had tried to bind in the normal fashion when I discovered it didn't work.
base2.DOM.bind($select.options);

But that didn't work, but that was probably overkill for the desired outcome.

I didn't think to do it the way you suggested.

But no, if you don't put it in, no skin off my back.  It's just a convenience.

Original comment by richy...@gmail.com on 4 Apr 2008 at 1:15

GoogleCodeExporter commented 9 years ago
Cool. This is a "Won't Fix" then. :-)

Original comment by dean.edw...@gmail.com on 4 Apr 2008 at 2:37