#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: |
Description
$('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
comment:2 Changed 13 years ago by
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
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
Component: | core → selector |
---|---|
Milestone: | 1.4.3 → 1.5 |
Priority: | → low |
Status: | new → open |
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.
Thanks!
comment:5 Changed 12 years ago by
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
Passing a comma-delimited selector string to .find('c,d')
should be a very common use case!
In addition, because jQuery('foo', context)
uses jQuery(context).find('foo')
internally, .find
MUST support every selector that jQuery()
supports.
comment:7 Changed 12 years ago by
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 that were used and not-at-all "smart".
comment:8 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | open → closed |
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.
Closing.
(Thanks cowboy and boushley)
comment:9 Changed 12 years ago by
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!
This is fixed by this git commit in my fork. Awaiting a merge from my pull request. http://github.com/Phrogz/jquery/commit/e1cb09d65a61a5c7ade0f5585c298b7dbc211f63