Opened 13 years ago
Closed 12 years ago
#4425 closed defect (fixed)
[patch][ccla] Query doesn't handle queries by ID relative to a root node properly
Reported by: | guest | Owned by: | alex |
---|---|---|---|
Priority: | high | Milestone: | 1.3 |
Component: | Core | Version: | 0.9 |
Keywords: | Cc: | [email protected]… | |
Blocked By: | Blocking: |
Description (last modified by )
Lets say I have an HTML DOM element that does not belong to the current rendered page (maybe it was fetched from a remote page, or created programmatically). I then want to do some querying/parsing over this node and its children. Most operations of dojo.query (querying based on class, etc.) work properly. However, attempting to query based on id fails, as dojo.query uses dojo.byId (and therefore document.getElementById) to retrieve those elements.
If the purpose of dojo.query is to always fetch items relative to the provided root element, this is not the desired behavior. I've attached a sample test case, as well as a patch to dojo/_base/query.js which does find the appropriate element.
The source attached falls under the same CLA as Jared Jurkiewicz and Bill Keese.
Attachments (4)
Change History (19)
Changed 13 years ago by
Attachment: | queryTest.html added |
---|
Changed 13 years ago by
Changed 13 years ago by
Attachment: | query.js.diff added |
---|
Changed 13 years ago by
Attachment: | query.js.2.diff added |
---|
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
Owner: | changed from anonymous to alex |
---|
comment:3 Changed 13 years ago by
Milestone: | → 1.1 |
---|---|
Summary: | Query doesn't handle queries by ID relative to a root node properly → [patch][ccla] Query doesn't handle queries by ID relative to a root node properly |
comment:4 Changed 13 years ago by
Milestone: | 1.1 → 1.2 |
---|
Move all milestone 1.1 tickets to 1.2, except for reopened tickets and tickets opened after 1.1RC1 was released.
comment:5 Changed 12 years ago by
Description: | modified (diff) |
---|---|
Type: | defect → enhancement |
comment:6 Changed 12 years ago by
Type: | enhancement → defect |
---|
hrm, I think this really is a defect. It's a spec violation.
comment:7 Changed 12 years ago by
Status: | new → assigned |
---|
comment:8 Changed 12 years ago by
btw, this works as expected:
dojo.query('*[id="search_id"]',your_root_node)
comment:9 Changed 12 years ago by
Milestone: | 1.2 → 1.3 |
---|
as per today's meeting, punting these core bugs
comment:10 Changed 12 years ago by
Milestone: | 1.3 → future |
---|
comment:11 Changed 12 years ago by
comment:12 Changed 12 years ago by
comment:13 Changed 12 years ago by
comment:14 Changed 12 years ago by
comment:15 Changed 12 years ago by
Milestone: | future → 1.3 |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Another possible solution to this bug is allowing the caller to provide a function for finding elements based on ID, passed as an optional argument to dojo.query, like so:
This would obviously be a small API change by adding in an optional argument to dojo.query, but it would take the extra code (size and performance) out of core and require the developer to account for this (not-so-)special case of addressing DOM elements that aren't in the current document.