jQuery([undefined])[0] === jQuery([])[0]

eq() always returns a single element, so you'd only need to allow null/
NaN/""/etc to pass through, I guess:

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

On Mar 3, 11:46 am, Robert Katić <[email protected]> wrote:
> Since no one is correcting me, I will do it myself, again :)
>
> We always have to pass an array to pushStack because it will ensure
> that the value will not processed as an selector or html or document,
> but simply as an array with values to set.
>
> eq: function( i ) {
>     var j = i < 0 ? +i + this.length : i,
>         el = j in this ? [ this[j] ] : [];
>
>     return this.pushStack( el, 'eq', i )
>
> }
>
> We maybe can make an exception if the value is a node:
>
> eq: function( i ) {
>     var j = i < 0 ? +i + this.length : i,
>         el = this[ j ];
>
>     el = ( j in this ) ? ( el && el.nodeType ? el : [el] ) : [];
>
>     return this.pushStack( el, 'eq', i )
>
> }
>
> However, not sure if this solutions are significantly faster then the
> solution with slicing.
--~--~---------~--~----~------------~-------~--~----~
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