Opened 13 years ago
Closed 12 years ago
#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: | |
Blocked by: | Blocking: |
Description (last modified by )
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 (14)
comment:1 Changed 13 years ago by
Milestone: | 1.4.3 |
---|
comment:2 Changed 13 years ago by
Priority: | → low |
---|---|
Status: | new → open |
comment:3 Changed 12 years ago by
Milestone: | → 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:4 Changed 12 years ago by
Component: | misc → traversing |
---|
comment:6 Changed 12 years ago by
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 12 years ago by
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 12 years ago by
Description: | modified (diff) |
---|
+0, Not clear on the specific proposal here ... are we breaking code?
comment:11 Changed 12 years ago by
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:13 Changed 12 years ago by
Description: | modified (diff) |
---|---|
Milestone: | 1.next → 1.7 |
Priority: | low → blocker |
comment:14 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | open → closed |
We really need a clear solution here, rather than an ambiguous "needs improvement" in order to be a blocker.
Resetting milestone to future.