#9071 closed defect (fixed)
[regression] dojo.query matching too many elements
Reported by: | dante | Owned by: | alex |
---|---|---|---|
Priority: | high | Milestone: | 1.3.1 |
Component: | Query | Version: | 1.3.0 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
using a simple html set:
<div id="one"> <p class="one"><a>one</a></p> <div id="two"> <p class="two"><a>two</a></p> </div> </div>
the query 'div p' returns 3 elements. also 'div p a'. there are clearly only two p and a elements in the page. the queryies 'p' and 'p a' both pass, as they don't contain an embedded match.
failing unit test attached.
Attachments (1)
Change History (8)
Changed 12 years ago by
Attachment: | query-quirk.html added |
---|
comment:1 Changed 12 years ago by
Milestone: | tbd → 1.3.1 |
---|---|
Summary: | dojo.query matching too many elements → [regression] dojo.query matching too many elements |
This works in 1.2, fails in 1.3 (and trunk).
comment:2 Changed 12 years ago by
The test fails because there are two nested divs.
For example, dojo.query("div p"): the root.getElementsByTagName(query.getTag()) (query.js, line 1033) finds one node, p.two, when root is the inner div and two nodes, p.one and p.two again, when root is the outer div.
So the ret array contains three elements and the _zip function is never called (ret.nozip = true, line 1092).
Maybe the assumption root nodes > 0 => no dup.controls (line 1086) is correct only when there are no ancestor/descendant root nodes.
comment:3 Changed 12 years ago by
If ret.nozip is not needed on line 1092, then perhaps get rid of the if (x > 0) block also. From what I can tell, bag is never assigned otherwise in the filterDown function, and my cursory look at getElementsFunc and "bag" references seem to indicate bag is not modified underneath either. But it would be good to get confirmation from Alex on it.
comment:4 Changed 12 years ago by
Status: | new → assigned |
---|
comment:5 Changed 12 years ago by
comment:6 Changed 12 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:7 Changed 11 years ago by
Component: | Core → Query |
---|
first two pass, second two fail