Side navigation
#8075 closed feature (fixed)
Opened January 27, 2011 02:28PM UTC
Closed May 03, 2011 07:01PM UTC
Last modified March 13, 2012 06:04PM UTC
nextUntil, prevUntil and parentsUntil should accept more then just selectors
Reported by: | anonymous | Owned by: | |
---|---|---|---|
Priority: | high | Milestone: | 1.6 |
Component: | traversing | Version: | 1.5 |
Keywords: | neededdocs | Cc: | |
Blocked by: | Blocking: |
Description
Just as the title says. One way to make sure the "Until" methods accept more then just selectors is to use the filter method instead of jQuery().is from line 4556 from:
while ( cur && cur.nodeType !== 9 && ( until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
To:
while ( cur && cur.nodeType !== 9 && ( until === undefined || cur.nodeType !== 1 || !jQuery( cur ).filter(until)[0] )) {
Now, correct me if I'm wrong here. But assuming you are comparing two DOM nodes to each other. Wouldn't it be a lot faster to compare those right away, so a new jQuery instance won't be created on each iteration? This way you would get something like:
while ( cur && cur.nodeType !== 9 && ( until === undefined || cur.nodeType !== 1 || !( cur === until || jQuery( cur ).filter( until )[0])) ) {
Heck, we could even use matchesSelector between them with something like this:
!( cur === until || ( typeof until === "string" && jQuery.find.matchesSelector( cur, until ) ) || jQuery( cur ).filter( until )[0])
Any thoughts?
Attachments (0)
Change History (12)
Changed January 27, 2011 05:26PM UTC by comment:1
component: | unfiled → traversing |
---|---|
priority: | undecided → high |
Changed January 27, 2011 05:26PM UTC by comment:2
priority: | high → low |
---|
Changed January 27, 2011 05:29PM UTC by comment:3
owner: | → anonymous |
---|---|
status: | new → pending |
To increase the chances for this to make into the core you should make a pull request with the needed changes
Changed January 28, 2011 02:49PM UTC by comment:4
status: | pending → new |
---|
http://jsperf.com/nextuntil-tests
Created a small perf on this ticket. I think it could be optimized and enhanced.
Changed February 02, 2011 03:11AM UTC by comment:5
version: | 1.4.4 → 1.5 |
---|
Changed February 02, 2011 07:14PM UTC by comment:6
Changed February 06, 2011 04:08PM UTC by comment:7
milestone: | 1.next → 1.6 |
---|---|
priority: | low → high |
status: | new → open |
Increasing priority & retargeting due to potential performance benefits.
Changed April 16, 2011 09:58PM UTC by comment:8
milestone: | 1.6 → 1.next |
---|---|
owner: | anonymous |
status: | open → assigned |
Let's look at this for 1.7.
Changed May 03, 2011 06:43PM UTC by comment:9
As of jQuery 1.6 and the updated is() and find() methods this already works:
nextUntil: http://jsfiddle.net/asz7m/
prevUntil: http://jsfiddle.net/mXmSS/
parentsUntil: http://jsfiddle.net/n77ua/
Should the documentation and test-cases be updated?
Changed May 03, 2011 07:01PM UTC by comment:10
keywords: | → needsdocs |
---|---|
milestone: | 1.next → 1.6 |
resolution: | → fixed |
status: | assigned → closed |
type: | enhancement → feature |
Good point! Thanks JRSchild
Changed June 08, 2011 05:38AM UTC by comment:11
Working on this at the moment. We'll make sure to post updated examples, signatures and wordage, JRSchild. Thanks!
Changed June 13, 2011 05:08AM UTC by comment:12
keywords: | needsdocs → neededdocs |
---|
I've updated the docs on .nextUntil(), .prevUntil() and .parentsUntil() to reflect the changes in behaviour.