Bug Tracker

Modify

Ticket #10616 (closed bug: fixed)

Opened 2 years ago

Last modified 2 years ago

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:
Blocking: Blocked by:

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

comment:2 Changed 2 years ago by rwaldron

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

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

patch to follow

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

comment:3 Changed 2 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 2 years ago by anonymous

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

comment:5 Changed 2 years ago by rwaldron

The patch fixes coercion support

comment:6 Changed 2 years ago by Rick Waldron

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

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

Changeset: 7cbd7a640fb6590b0eb7cbedd83a8d46eb553c5a

comment:7 Changed 2 years ago by dmethvin

  • Milestone changed from 1.next to 1.7.1

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.