Side navigation
#6362 closed enhancement (invalid)
Opened March 26, 2010 06:22PM UTC
Closed July 25, 2011 04:11PM UTC
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
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()
Attachments (0)
Change History (14)
Changed November 12, 2010 02:40AM UTC by comment:1
milestone: | 1.4.3 |
---|
Changed November 19, 2010 07:31AM UTC by comment:2
priority: | → low |
---|---|
status: | new → open |
Changed April 16, 2011 11:19PM UTC by comment:3
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.
Changed April 17, 2011 11:45PM UTC by comment:4
component: | misc → traversing |
---|
Changed May 22, 2011 07:27PM UTC by comment:5
keywords: | → 1.7-discuss |
---|
Nominating ticket for 1.7 discussion.
Changed May 22, 2011 10:13PM UTC by comment:6
_comment0: | +1, This seems like "indexOf", but for jQuery selector result objects, in which case, I support a semantically named implementation → 1306103028758151 |
---|---|
description: | 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() → 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() |
+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/
Changed May 22, 2011 11:59PM UTC by comment:7
+1, Makes sense to me
Changed May 23, 2011 01:57AM UTC by comment:8
description: | 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() → 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() |
---|
+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.
Changed May 23, 2011 03:10AM UTC by comment:9
description: | 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() → 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() |
---|
+1, why not
Changed May 23, 2011 09:30PM UTC by comment:10
description: | 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() → 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() |
---|
+0, Not clear on the specific proposal here ... are we breaking code?
Changed June 03, 2011 01:28PM UTC by comment:11
description: | 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() → 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() |
---|
+1, I'm not sure about indexIn but we should definitely look to change the semantics of .index(String) to make it more useful.
Changed June 06, 2011 03:42PM UTC by comment:12
+0
Changed July 12, 2011 02:50PM UTC by comment:13
description: | 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() → 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() |
---|---|
milestone: | 1.next → 1.7 |
priority: | low → blocker |
Changed July 25, 2011 04:11PM UTC by comment:14
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.