Ticket #6362 (closed enhancement: invalid)
jQuery.index() and jQuery.indexIn()
| Reported by: | jablko | Owned by: | |
|---|---|---|---|
| Priority: | blocker | Milestone: | 1.7 |
| Component: | traversing | Version: | 1.4.2 |
| Keywords: | 1.7-discuss | Cc: | |
| Blocking: | Blocked by: |
Description (last modified by dmethvin) (diff)
The semantics of jQuery.index() are backwards depending whether you pass an element or a selector as an argument, http://api.jquery.com/index/
I wish the semantics were consistent, so this example,
var $href = $('[href]', data);
var index = $href.index($href.filter('[href="' + location + '"]'));
- could be reduced to,
var $href = $('[href]', data);
var index = $href.index('[href="' + location + '"]');
I wish the two backwards semantics had two different names, e.g. jQuery.index() and jQuery.indexIn(), analogous to jQuery.append() and jQuery.appendTo()
Change History
comment:3 Changed 2 years ago by john
- Milestone set to 1.next
We should look at this for 1.7 - I'm not convinced that the old way of .index() working really makes sense for our API.
comment:5 Changed 2 years ago by john
- Keywords 1.7-discuss added
Nominating ticket for 1.7 discussion.
comment:6 Changed 2 years ago by rwaldron
- Description modified (diff)
+1, This seems like "indexOf", but for jQuery selector result objects, in which case, I support a semantically named implementation, perhaps similar to: http://jsfiddle.net/rwaldron/9R9kP/
comment:8 Changed 2 years ago by ajpiano
- Description modified (diff)
+0, I thought we made it work like the OP requested for 1.4. I suppose that having better named methods as opposed to argument-type magic would be an improvement.
comment:10 Changed 2 years ago by dmethvin
- Description modified (diff)
+0, Not clear on the specific proposal here ... are we breaking code?
comment:11 Changed 2 years ago by john
- Description modified (diff)
+1, I'm not sure about indexIn but we should definitely look to change the semantics of .index(String) to make it more useful.
comment:12 Changed 2 years ago by jzaefferer
+0
comment:13 Changed 2 years ago by dmethvin
- Priority changed from low to blocker
- Description modified (diff)
- Milestone changed from 1.next to 1.7
comment:14 Changed 2 years ago by john
- Status changed from open to closed
- Resolution set to invalid
We really need a clear solution here, rather than an ambiguous "needs improvement" in order to be a blocker.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Resetting milestone to future.