Bug Tracker

Opened 11 years ago

Closed 9 years ago

#4596 closed feature (wontfix)

find function including the results of filter?

Reported by: kazar Owned by:
Priority: low Milestone: 1.next
Component: traversing Version: 1.3.2
Keywords: Cc:
Blocked by: Blocking:

Description (last modified by Rick Waldron)

Hi,

Just an idea - I often find myself doing something like:

$(this).filter(".a-class").add($(this).find(".a-class"));

I (personally) find this a bit clunky. Was wondering if it was sensible to perhaps make find include the results of a filter over the set of elements, so i would just have to do this:

$(this).find(".a-class", { withset: true });

(or something along those lines), just seems cleaner to me, especially because I seem to end up doing that first bit of code a lot.

Cheers

Change History (16)

comment:1 Changed 9 years ago by dmethvin

Component: unfiledtraversing

comment:2 Changed 9 years ago by Rick Waldron

Keywords: needsreview added
Milestone: 1.41.5
Priority: triviallow

comment:3 Changed 9 years ago by john

Milestone: 1.next
Status: newopen

Let's consider this for 1.7, I've often wanted a method similar to this - perhaps something like .findFilter().

comment:4 Changed 9 years ago by john

Keywords: 1.7-discuss added

Nominating ticket for 1.7 discussion.

comment:5 Changed 9 years ago by dmethvin

+1, Useful, small, and easy to document.

comment:6 Changed 9 years ago by Rick Waldron

Description: modified (diff)

-1, can be easily accomplished with existing api; proposal is confusing

comment:7 Changed 9 years ago by jaubourg

+0, If it's small, why not, if not then meh.

comment:8 Changed 9 years ago by ajpiano

Description: modified (diff)

+0, I think this is kind of confusing as "findFilter," can we come up with a better name, at least?

comment:9 Changed 9 years ago by timmywil

Description: modified (diff)

+0, possibly as a new function to make the API clear.

comment:10 Changed 9 years ago by danheberden

-1, i think adding more options just muddles up the api - it's easily possible with the current API and a plugin could be written to make $.fn.findAndAdd or something

comment:11 Changed 9 years ago by john

+1, I find myself doing this (or equivalent) all the time. I don't agree with the API proposed (it should be much simpler, like .filterFind()).

comment:12 Changed 9 years ago by scottgonzalez

+1, I really don't like the proposed API, but I'm in favor of a new method with this functionality

comment:13 Changed 9 years ago by addyosmani

+0

comment:14 Changed 9 years ago by jzaefferer

-1, too similar to #4446: .find("a.class").andSelf(".a-class")

comment:15 Changed 9 years ago by cowboy

-1, No need for a separate method or option, as this could be accomplished with #4446 $(this).find(selector).andSelf(selector);

comment:16 Changed 9 years ago by Rick Waldron

Description: modified (diff)
Keywords: needsreview 1.7-discuss removed
Resolution: wontfix
Status: openclosed
Note: See TracTickets for help on using tickets.