Skip to main content

Bug Tracker

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 addyosmani comment:1

component: unfiledtraversing
priority: undecidedlow
status: newopen
type: bugenhancement

Marking as valid, switching to enhancement and opening for discussion.

Changed January 02, 2012 06:13PM UTC by dmethvin comment:2

milestone: None1.8

Changed January 04, 2012 07:20AM UTC by gibson042 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 gibson042 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 rwaldron comment:5

owner: → rwaldron
status: openassigned

Noticed this was unowned for 1.8

Changed May 13, 2012 04:44PM UTC by dmethvin comment:6

owner: rwaldrondmethvin
summary: New method: .addPrior (supersedes .andSelf)New method: .addBack (supersedes .andSelf)

PR for discussion as .addBack().

https://github.com/jquery/jquery/pull/777

Changed May 16, 2012 03:15AM UTC by rwaldron comment:7

resolution: → fixed
status: assignedclosed

Changed May 24, 2012 03:19PM UTC by cowboy comment:8

resolution: fixed
status: closedreopened

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 dmethvin comment:9

@cowboy can you submit a pull request?

Changed May 29, 2012 12:13AM UTC by timmywil comment:10

status: reopenedopen

Changed May 29, 2012 03:56PM UTC by cowboy comment:11

Changed May 29, 2012 04:04PM UTC by Ben Alman comment:12

resolution: → fixed
status: openclosed

jQuery#addBack supports an optional selector that can be used to filter the prior set before adding it back. Fixes #9800

Changeset: 02dd7c570bf4dbbdfc168f4352d04c667447be5d