Nice catch. The reason we are passing 2 arguments is JavaScript future
compatibility: the JS 1.6 stuff already implemented in Firefox is likely to
be a part of ECMAScript. Actually, Firefox passes 3 arguments:
http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:map

What you stumbled upon could be pretty confusing at first even for a
seasoned developer, but I don't think there's much we can do about it. But
you'll find that iteration combined with DOM traversal methods could be
easily solved with better CSS selectors; for instance $$('[type=radio] +
label') ... We could try and educate people towards that.


On Dec 4, 2007 5:23 PM, John-David Dalton <[EMAIL PROTECTED]>
wrote:

>
> Hi guys,
>
> This is really not a bug but I thought I would bring it to your
> attention.
>
> $$('[type=radio]').map(function(el){return el.next()}); // => [label,
> label]
> $$('[type=radio]').map(Element.next); // => [label, undefined]
>
> The "map" method is passing 2 params to the iterator.
> This makes the Element.next() go nuts cause its second param is used
> for sibling offset.
>
> In PHP array_map only passes the "value" and not the index.
> It makes since for Enumerable.each() to send both, but I think map
> should be left to just the value. I image there are more cases where
> this sort or error would occur.
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to