Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#13658 closed defect (fixed)

dojo.query $= returns incorrect elements

Reported by: CraigMorgan Owned by: Kris Zyp
Priority: high Milestone: 1.7.5
Component: Query Version: 1.6.1
Keywords: Cc:
Blocked By: Blocking:

Description

This bug is occuring for me in IE9, but I believe it will be reproducible in all browsers without QSA (querySelectorAll) functionality available.
Example
In case the above link fails, here's the example:
javascript:

//dojo.require("dojo.query");

dojo.ready(function() {
  
  var nodeList = dojo.query("div[id$='55555']", dojo.byId('other'));
  nodeList .forEach(function(node) {
    console.log("result: ", node.outerHTML);
  });
  console.log("nodeList: ", nodeList);
});

html:

<div id='other'>
  <div id='abc55555'></div>
  <div id='abd55555efg'></div>
  <div id='55555abc'</div>
  <div id='1'></div>
  <div id='2c'></div>
  <div id='3ch'></div>
  <div id='4chr'></div>
  <div id='5char'></div>
  <div id='6chars'></div>
</div>

The above example should only output <div id='abc55555'></div> to console. Instead, it also outputs <div id='3ch'></div>.

The bug is in the line "return (ea.lastIndexOf(value)==(ea.length-value.length));", which can be found on line 452 of query.js .

Change History (7)

comment:1 Changed 8 years ago by CraigMorgan

Sorry about the summary, I forgot to finish it. It should be something like "dojo.query $= returns incorrect elements", but I can't see how to change it now.

comment:2 Changed 8 years ago by bill

Component: GeneralQuery
Owner: set to Kris Zyp
Summary: dojo.query '$='dojo.query $= returns incorrect elements

comment:3 Changed 8 years ago by Kris Zyp

Resolution: fixed
Status: newclosed

In [27534]:

Fix $= query handling, fixes #13658 !strict

comment:4 Changed 8 years ago by bill

Milestone: tbd1.8

comment:5 Changed 8 years ago by bill

#9497 is a duplicate of this ticket.

comment:6 Changed 7 years ago by Colin Snover

In [30041]:

Fix $= query handling, fixes #13658 !strict Backport to 1.7

comment:7 Changed 7 years ago by Colin Snover

Milestone: 1.81.7.5
Note: See TracTickets for help on using tickets.