Bug Tracker

Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#6754 closed bug (invalid)

a.find(b) produces bad selector if a or b have grouped selectors

Reported by: Phrogz Owned by:
Priority: low Milestone: 1.5
Component: selector Version: 1.4.2
Keywords: find pushstack selector Cc:
Blocked by: Blocking:


$('a,b').find('c,d').selector should produce something like 'a c,a d,b c,b d'. Instead, it produces 'a,b c,d' in jQuery 1.4.2.

This breaks any code that uses the selector for future live-like selections or tests.

Change History (10)

comment:1 Changed 13 years ago by Phrogz

This is fixed by this git commit in my fork. Awaiting a merge from my pull request. http://github.com/Phrogz/jquery/commit/e1cb09d65a61a5c7ade0f5585c298b7dbc211f63

comment:2 Changed 13 years ago by Phrogz

Oops; that commit had some text accidentally deleted right before commit. Corrected commit here: http://github.com/Phrogz/jquery/commit/1410deb1fd20eeed4482cc7a10f11f069c7bda82

comment:3 Changed 12 years ago by boushley

Here's a link for a valid jsfiddle test case http://jsfiddle.net/boushley/eJrV5/ I can't speak to the validity of the commits however.

comment:4 Changed 12 years ago by SlexAxton

Component: coreselector
Priority: low
Status: newopen

This seems like a better representation of what he's asking: http://jsfiddle.net/SlexAxton/eJrV5/1/

I am not sure jQuery intentionally tries to support comma delimited selectors in a find() statement. It definitely has never supported this, so it isn't a regression, but I consider it something that seems like it should work. Until then, you can just use an add() statement or be explicit.


comment:5 Changed 12 years ago by boushley

Here's an updated fiddle that better shows the fact that two different sets are selected. http://jsfiddle.net/boushley/eJrV5/4/

comment:6 Changed 12 years ago by cowboy

n/m this comment!

Last edited 12 years ago by cowboy (previous) (diff)

comment:7 Changed 12 years ago by cowboy

Oops.. I mis-read the description. That .selector property... People need to be made to understand that it's a very rough representation of the selectors and not-at-all "smart".

Version 1, edited 12 years ago by cowboy (previous) (next) (diff)

comment:8 Changed 12 years ago by SlexAxton

Resolution: invalid
Status: openclosed

OK. I think I see what these guys are pointing out. The .selector property is not actually used for the selection, so it's not a good determination of jQuery's support for comma delimited selectors in the 'find' method. In fact, the selection should work just fine (as seen in boushley's fiddle), but the .selector property is just the two selectors concatenated together. It shouldn't be used for testing the final selector that is used.


(Thanks cowboy and boushley)

comment:9 Changed 12 years ago by dmethvin

A couple of points here. One, it's not valid to use a .live() selector after a .find().

DOM traversal methods are not fully supported for finding elements to send to .live(). Rather, the .live() method should always be called directly after a selector, as in the example above. -- http://api.jquery.com/live/

Two, the .selector property is not publicly documented. Don't look at it!

comment:10 Changed 12 years ago by dmethvin

#10224 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.