Side navigation
#4302 closed bug (worksforme)
Opened March 05, 2009 06:22PM UTC
Closed November 17, 2010 01:55AM UTC
jQuery doesn't filter (and probably everything else) child selector properly
Reported by: | vidmich | Owned by: | john |
---|---|---|---|
Priority: | major | Milestone: | 1.4 |
Component: | selector | Version: | 1.3.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
jQuery('<div><div class="cls1"><div class="cls2"><div><div class="cls2"><div class="cls3"></div></div></div></div></div></div>').find('.cls1 > .cls2 .cls3').length === 1
should be true
having elements with classes .cls1 .cls2 .cls2 .cls3
selector '.cls1 > .cls2 .cls3' returns 0 elements
propably cause jQuery stop searching correct pattern of parents when found that nearset .cls2 parent have no .cls1 parent...
Attachments (1)
Change History (2)
Changed March 22, 2009 06:33PM UTC by comment:1
Changed November 17, 2010 01:55AM UTC by comment:2
resolution: | → worksforme |
---|---|
status: | new → closed |
http://jsfiddle.net/dmethvin/uEL2c/
Must have been fixed at some point.
I've encountered this bug too. Here are my findings:
It looks like
>
,+
and~
combinators are too pessimistic -- if they fail to match on the first element they're tested against, jQuery will refuse to test any ancestors.I've created a test case but there are many more subtleties my test case doesn't capture. Consider testing the selector
'.a > .b > .c *'
against the DOM tree represented by'.a > .b > .b.c > .c > x'
-- when'.a'
fails to match on.b
, it needs to backtrack one element and resume testing from'.c'
to find the match. Chains of>
and+
need to be treated like units.