Bug Tracker

Modify

Ticket #5476 (closed enhancement: fixed)

Opened 4 years ago

Last modified 3 years ago

Prevent get(-1) to create a new jQuery object

Reported by: rkatic Owned by: jitter
Priority: high Milestone: 1.5
Component: core Version: 1.4.4
Keywords: get, slice Cc:
Blocking: Blocked by:

Description

Instead of

( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );

you will write

( num < 0 ? slice.call(this, num)[ 0 ] : this[ num ] );

or even better (for me)

( num < 0 ? this[ this.length - num ] : this[ num ] );

Change History

comment:1 Changed 4 years ago by rkatic

oops, wrong sign

( num < 0 ? this[ this.length + num ] : this[ num ] );

comment:2 Changed 3 years ago by snover

  • Owner set to rkatic
  • Status changed from new to pending

Sorry, what is the issue here? What use case is there for this?

comment:3 Changed 3 years ago by rkatic

  • Status changed from pending to new

.get(Number) returns a single element. It is unnecessary and relatively expensive to create a new jQuery object calling .slice() only to get a single value.

comment:4 Changed 3 years ago by jitter

  • Priority changed from major to high
  • Status changed from new to open
  • Version changed from 1.3.2 to 1.4.4
  • Milestone set to 1.5

 pull request

 performance test improvement >90%

 test case which shows get() new vs old

Last edited 3 years ago by jitter (previous) (diff)

comment:5 Changed 3 years ago by snover

  • Owner changed from rkatic to jitter
  • Status changed from open to assigned

comment:6 Changed 3 years ago by john

  • Status changed from assigned to closed
  • Resolution set to fixed
  • Milestone changed from 1.5 to 1.4.5

Landed.

comment:7 Changed 3 years ago by jitter

  • Milestone changed from 1.4.5 to 1.5

Move fixed tickets to appropriate milestone

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.