Bug Tracker

Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#10616 closed bug (fixed)

Type coersion not done for -1 in .eq

Reported by: anonymous Owned by: rwaldron
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 5 years ago by rwaldron

  • Component changed from unfiled to core
  • Owner set to rwaldron
  • Priority changed from undecided to low
  • Status changed from new to assigned

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

patch to follow

Last edited 5 years ago by rwaldron (previous) (diff)

comment:3 Changed 5 years ago by rwaldron

  • Milestone changed from None to 1.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 4 years ago by anonymous

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

comment:5 Changed 4 years ago by rwaldron

The patch fixes coercion support

comment:6 Changed 4 years ago by Rick Waldron

  • Resolution set to fixed
  • Status changed from assigned to closed

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

Changeset: 7cbd7a640fb6590b0eb7cbedd83a8d46eb553c5a

comment:7 Changed 4 years ago by dmethvin

  • Milestone changed from 1.next to 1.7.1
Note: See TracTickets for help on using tickets.