> eq: function( i ) {
>     var el = [ this[ i<0 ? i+this.length : i] ];
>     if (el[0] === undefined) el.length = 0;
>     return this.pushStack( el, 'eq', i );
>
> };

Yes, I supposed it was an mistyping. Now this is safe in case of "out
of range" but is not in case with an undefined value as element. ( +i
+ this.length is to make eq(i) safe in cases where i is an string )


> It doesn't seem possible to pass the undefined object along. Anyone
> doing that? $(undefined) and $(null) are also unsupported.

Of course it is possible, even if jquery is mainly an container of
elements.
I saw usages of $.fn.map which callback returns non-element values. I
know that in that cases an $.map is more appropriate, but the current
implementation allows both approaches.

$(undefined) and $(null) works fine and are equally to $() and $
(document). Does these are supported or not is not relevant here, I
think.

I would like to have an John opinion if we have to support undefined
values inside an jquery object, and would it be dangerous to break
this support.

>
> On Mar 3, 5:47 pm, Robert Katić <[email protected]> wrote:
>
> > > jQuery([undefined])[0] === jQuery([])[0]
>
> > Yes, but
>
> >     jQuery([undefined]).length !== jQuery([]).length
>
> > > eq() always returns a single element, so you'd only need to allow null/
> > > NaN/""/etc to pass through, I guess:
>
> > In the current implementation, eq(i) returns the value (not only
> > nodes) at index i, if i is not out of range.
> > In case of "out of range" it returns an "empty" jquery.
>
> > > eq: function( i ) {
> > >     var el = [ this[ i<0 ? i+this.length : i] ];
> > >     if (el === undefined) el = [];
> > >     return this.pushStack( el, 'eq', i )
>
> > > }
>
> > Your solution will return "jQuery([undefined])" in case of "out of
> > range" insted of an "jQuery([])",
> > and el will always be an array, so (el === undefined) will never be
> > true.
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to