Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#10616 closed bug (fixed)

Type coersion not done for -1 in .eq

Reported by: anonymous Owned by: Rick Waldron
Priority: low Milestone: 1.7.1
Component: core Version: 1.7b2
Keywords: Cc:
Blocked by: Blocking:

Description

Test case: http://jsfiddle.net/pimvdb/NZdAa/1/

Proposed fix:

eq: function( i ) {
    return +i === -1 ?
        this.slice( i ) :
        this.slice( i, +i + 1 );
},

instead of

eq: function( i ) {
    return i === -1 ?
        this.slice( i ) :
        this.slice( i, +i + 1 );
},

(Notice the extra +.)

Change History (7)

comment:2 Changed 12 years ago by Rick Waldron

Component: unfiledcore
Owner: set to Rick Waldron
Priority: undecidedlow
Status: newassigned

Another perspective on the test case: http://jsfiddle.net/rwaldron/NZdAa/4/

patch to follow

Last edited 12 years ago by Rick Waldron (previous) (diff)

comment:3 Changed 12 years ago by Rick Waldron

Milestone: None1.next

Regardless of whether or not type coercion occurs within this function's body, the documented api says "index" which it defines as an "integer", but not as a string.

https://github.com/jquery/jquery/pull/568

comment:4 Changed 12 years ago by anonymous

Yes, I guess removing type coercion altogether would not be a bad idea.

comment:5 Changed 12 years ago by Rick Waldron

The patch fixes coercion support

comment:6 Changed 12 years ago by Rick Waldron

Resolution: fixed
Status: assignedclosed

Coerce eq() argument all the time. Fixes #10616

Changeset: 7cbd7a640fb6590b0eb7cbedd83a8d46eb553c5a

comment:7 Changed 12 years ago by dmethvin

Milestone: 1.next1.7.1
Note: See TracTickets for help on using tickets.