Well if $() is same as $([]), then instead of

if ( !selector ) {
  return this;
}

in $.fn.init, we can put

if ( selector == null ) {
  return this;
}

This would eliminate the $(0) "unexpected" behavior.

On Nov 1, 3:28 pm, John Resig <jere...@gmail.com> wrote:
> This changed slightly in the latest nightlies - if you do $(0) it'll
> be as if you did $() or $([]). As of now any false-ish value will give
> you an empty jQuery set.
>
> Considering that there is no intended behavior for passing in a number
> to the jQuery object this seems fine to me.
>
> I'm curious - why were you passing in a number to the jQuery object? I
> could sort of, kind of, understand passing in an array of values - but
> just one number doesn't make sense.
>
> --John
>
> On Sat, Oct 31, 2009 at 9:16 PM, Xavier Shay <xavier.s...@gmail.com> wrote:
> >> $(0).get(0)
> > Document
> >> $(1).get(0)
> > 1
> >> $(2).get(0)
> > 2
>
> > Why does $(0) return a document? Is this intended behaviour? I would
> > expect it to return 0.
>
> > --
>
> > You received this message because you are subscribed to the Google Groups 
> > "jQuery Development" group.
> > To post to this group, send email to jquery-...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > jquery-dev+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/jquery-dev?hl=en.

--

You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-...@googlegroups.com.
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en.


Reply via email to