Modify ↓
Ticket #5476 (closed enhancement: fixed)
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: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 2 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
comment:5 Changed 2 years ago by snover
- Owner changed from rkatic to jitter
- Status changed from open to assigned
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

oops, wrong sign