Opened 11 years ago
Closed 11 years ago
#11458 closed defect (fixed)
[patch] [cla] Nodelist.closest() doesn't match descendant selectors
Reported by: | bill | Owned by: | bill |
---|---|---|---|
Priority: | high | Milestone: | 1.6 |
Component: | Core | Version: | 1.5 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
See test case attached to #11457.
dojo.query(".bang").closest(".foo > .bar")
is run on the following HTML:
<div id="level3" class="foo"> <div id="level4" class="bar"> <div id="level5" class="bar"> <div id="level6" class="bang">foo bar bar bang</div> </div> </div> </div>
Closest() should find "level4" but it doesn't, it returns []. Similarly this query should also find "level4", but it doesn't:
dojo.query(".bang").closest(".foo .bar")
The patch in #11457 fixes this bug.
Attachments (1)
Change History (6)
comment:1 Changed 11 years ago by
Milestone: | tbd → 1.6 |
---|---|
Owner: | changed from anonymous to bill |
Status: | new → assigned |
comment:2 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:3 Changed 11 years ago by
Resolution: | fixed |
---|---|
Status: | closed → reopened |
dojo.query('.bang').closest('> .bar', 'level3');
should find ['level4']
but doesn't. attaching a patch for tests to include this case.
Changed 11 years ago by
Attachment: | 11458-test.diff added |
---|
comment:4 Changed 11 years ago by
Good catch, there are a couple problems you've found, in that
dojo.query('.bang').closest('> .bar');
wasn't working correctly either (it should return no results since there are no .bar directly under <body>. I'll patch up the code adding your testcase and another one too.
comment:5 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | reopened → closed |
(In [22537]) Make simple-filter check stricter, so that "> div" isn't classified as a simple filter. Also remove query argument from closest()'s call to _getRelatedUniqueNodes(), since it seems unnecessary (the filter has already been applied) and also since it won't work correctly without also passing in the root node that the query is relative to. Fixes #11457, #11458 !strict.
(In [22528]) Fix/enhance dojo._filterQueryResult(), NodeList.closest(), NodeList.orphan(), and NodeList.filter() to work on descendant selectors like "div > span", yet to work efficiently for simple selectors like ".foo". Fixes #11457, #11458 !strict.
Also, enhanced NodeList.closest() to take an optional root parameter (same as dojo.query()'s root parameter). If root is specified, the selector is relative to that node rather than the document root. This parameter will be useful for future NodeList.delegate(). Refs #11459.