Bug Tracker

Modify

Ticket #4596 (closed feature: wontfix)

Opened 4 years ago

Last modified 2 years ago

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:
Blocking: Blocked by:

Description (last modified by rwaldron) (diff)

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

comment:1 Changed 3 years ago by dmethvin

  • Component changed from unfiled to traversing

comment:2 Changed 3 years ago by rwaldron

  • Keywords needsreview added
  • Priority changed from trivial to low
  • Milestone changed from 1.4 to 1.5

comment:3 Changed 2 years ago by john

  • Status changed from new to open
  • Milestone set to 1.next

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

comment:4 Changed 2 years ago by john

  • Keywords needsreview,1.7-discuss added; needsreview removed

Nominating ticket for 1.7 discussion.

comment:5 Changed 2 years ago by dmethvin

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

comment:6 Changed 2 years ago by rwaldron

  • Description modified (diff)

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

comment:7 Changed 2 years ago by jaubourg

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

comment:8 Changed 2 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 2 years ago by timmywil

  • Description modified (diff)

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

comment:10 Changed 2 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 2 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 2 years ago by scott.gonzalez

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

comment:13 Changed 2 years ago by addyosmani

+0

comment:14 Changed 2 years ago by jzaefferer

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

comment:15 Changed 2 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 2 years ago by rwaldron

  • Keywords needsreview,1.7-discuss removed
  • Status changed from open to closed
  • Resolution set to wontfix
  • Description modified (diff)

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.