Side navigation
#9800 closed enhancement (fixed)
Opened July 11, 2011 07:24PM UTC
Closed May 29, 2012 04:04PM UTC
New method: .addBack (supersedes .andSelf)
| Reported by: | cowboy | Owned by: | dmethvin |
|---|---|---|---|
| Priority: | low | Milestone: | 1.8 |
| Component: | traversing | Version: | 1.6.2 |
| Keywords: | Cc: | ||
| Blocked by: | Blocking: |
Description
Ok. .andSelf is somewhat confusingly named. What is "self" anyways? Let's come up with a better name for this method, and in the process, add a signature by which the previous-set-of-elements-to-be-added may be filtered. How about .addPrior? It's like .add but it specifically adds elements from the prior set.
Here's a version, as a plugin, with some usage examples: https://gist.github.com/1076570
Note: .andSelf should just be aliased to this new method, and documented as deprecated. We wouldn't need to change the docs for .andSelf, since it would still behave normally.
Attachments (0)
Change History (12)
Changed July 11, 2011 08:52PM UTC by comment:1
| component: | unfiled → traversing |
|---|---|
| priority: | undecided → low |
| status: | new → open |
| type: | bug → enhancement |
Changed January 02, 2012 06:13PM UTC by comment:2
| milestone: | None → 1.8 |
|---|
Changed January 04, 2012 07:20AM UTC by comment:3
I like that this enhances the chain-stack analogy where filters/traversals/etc. push, .end() pops, and .prevObject peeks.
Changed January 04, 2012 03:47PM UTC by comment:4
I've thought a bit more about this, and would like to propose .addBack instead of .addPrior: #11128
Changed March 05, 2012 08:31PM UTC by comment:5
| owner: | → rwaldron |
|---|---|
| status: | open → assigned |
Noticed this was unowned for 1.8
Changed May 13, 2012 04:44PM UTC by comment:6
| owner: | rwaldron → dmethvin |
|---|---|
| summary: | New method: .addPrior (supersedes .andSelf) → New method: .addBack (supersedes .andSelf) |
PR for discussion as .addBack().
Changed May 16, 2012 03:15AM UTC by comment:7
| resolution: | → fixed |
|---|---|
| status: | assigned → closed |
Changed May 24, 2012 03:19PM UTC by comment:8
| resolution: | fixed |
|---|---|
| status: | closed → reopened |
I'm re-opening this, because the second half of the ticket, "...in the process, add a signature by which the previous-set-of-elements-to-be-added may be filtered..." wasn't addressed, and I'd hate to see it get lost because it's so useful.
See https://gist.github.com/1076570 "find+filter" example for reference.
Changed May 24, 2012 03:24PM UTC by comment:9
@cowboy can you submit a pull request?
Changed May 29, 2012 12:13AM UTC by comment:10
| status: | reopened → open |
|---|
Changed May 29, 2012 03:56PM UTC by comment:11
@dmethvin done. https://github.com/jquery/jquery/pull/803
Changed May 29, 2012 04:04PM UTC by comment:12
| resolution: | → fixed |
|---|---|
| status: | open → closed |
jQuery#addBack supports an optional selector that can be used to filter the prior set before adding it back. Fixes #9800
Changeset: 02dd7c570bf4dbbdfc168f4352d04c667447be5d
Marking as valid, switching to enhancement and opening for discussion.