Opened 11 years ago

Closed 11 years ago

Last modified 10 years ago

#7211 closed defect (fixed)

Inconsistency in dojo.query for scoped queries

Reported by: Ben Lowery Owned by: alex
Priority: high Milestone: 1.3
Component: Query Version: 1.1.1
Keywords: Cc:
Blocked By: Blocking:

Description

Assuming I have

<div id="scope"><p class="awesome">awesome</p></div>

the following queries, which seem from inspection to be equivalent, return inconsistent things:

dojo.query("#notThere .awesome");
// |
// \-> yields zero elements
dojo.query(".awesome", "notThere"); 
// |
// \-> yields one element 

The varying behavior is due to dojo.query taking the second argument, passing it through dojo.byId and then taking the null return to mean that the user called dojo.query like this:

dojo.query(".awesome", null);
// which is equivalent to
dojo.query(".awesome");

I suggest possibly returning zero elements if the second parameter is null and only defaulting to searching the entire document if the second parameter is undefined. This would have a backwards-compat impact, but I feel that the current behavior is a bug.

Change History (6)

comment:1 Changed 11 years ago by Adam Peller

Owner: changed from anonymous to alex

comment:2 Changed 11 years ago by dylan

Milestone: tbd1.2

comment:3 Changed 11 years ago by bill

Milestone: 1.21.3

as per today's meeting, punting these core bugs

comment:4 Changed 11 years ago by alex

Status: newassigned

comment:5 Changed 11 years ago by alex

Resolution: fixed
Status: assignedclosed

(In [16420]) handle the case where a failed scope lookup would otherwise cause us to search the entire docment. Instead, return an empty NodeList?. Adds test for this case. Fixes #7211. !strict

comment:6 Changed 10 years ago by bill

Component: GeneralQuery
Note: See TracTickets for help on using tickets.