Opened 10 years ago

Closed 8 years ago

Last modified 7 years ago

#10651 closed defect (fixed)

[regression] [patch] [cla] dojo.query not working for attribute selector that includes a tilde (~) character

Reported by: juzzam Owned by: bill
Priority: low Milestone: 1.7.5
Component: Query Version: 1.4.0
Keywords: dojo.query Cc: Karl Tiedt
Blocked By: Blocking:

Description (last modified by bill)

dojo.query fails to query an attribute selector with a value including a tilde character which should be supported (the value encapsulated in quotes of an attribute selector is a CSS String which can have this character). This has been confirmed to work with jquery by Les Szklanny on the dojo-interest list.

A code example is attached.

Attachments (4)

test.html (525 bytes) - added by juzzam 10 years ago.
query_with_plus.html (704 bytes) - added by Michael Bannister 10 years ago.
query_infix.patch (2.2 KB) - added by Karl Tiedt 10 years ago.
possible fix for 10651 (renamed to .patch)
query_infix2.patch (2.2 KB) - added by Michael Bannister 9 years ago.
possible fix for 10651 (corrected)

Download all attachments as: .zip

Change History (26)

Changed 10 years ago by juzzam

Attachment: test.html added

comment:1 Changed 10 years ago by Adam Peller

Component: CoreQuery
Owner: changed from anonymous to alex

comment:2 Changed 10 years ago by Karl Tiedt

Cc: Karl Tiedt added

Updating this with the info I sent to the ML

The problem has been isolated, a fix is in the works, might be worth not jumping the jQuery ship just yet ;)

In the interest of a regex guru out there here are the problem lines

http://scsys.co.uk:8002/38390 (ignore the line #s thats with debug code added, the real line #'s are 1187-1198

output from the debugging lines show (irrelevant debug snipped)

a[href="http://abc.com/~123"] before infixSpaceRe a[href="http://abc.com/ ~ 123"] after infixSpaceRe

a[href="http://abc.com/_123"] before infixSpaceRe a[href="http://abc.com/_123"] after infixSpaceRe

comment:3 Changed 10 years ago by Adam Peller

Summary: dojo.query not working for attribute selector that includes a tilda (~) character[regression]dojo.query not working for attribute selector that includes a tilda (~) character

see r20851

comment:4 Changed 10 years ago by James Burke

Fixing this will be difficult without compromising the "normalize missing spaces in a query" fix. In the meantime though, this kind of chain can help avoid the issue:

dojo.query('a[href*="http://abc.com/"]').filter(function(node){ return node.href.indexOf("~") !== -1; })

comment:5 Changed 10 years ago by Douglas Hays

Does this work?

var infixSpaceRe = /"[^"]*"|'[^']*'|n\+\d|([^ ])?([>~+])([^ =])?/g;

comment:6 Changed 10 years ago by Michael Bannister

I'm finding the same thing with plus (+) in a query like this:

dojo.query('option[value="abc+def"]', selectNode);

I've tried it without the scope, too, though in my case the code is out of my control as it's part of setting up a dijit.form.FilteringSelect? using a <select> element. I'll try to set up and attach a test case later.

This is blocking my project upgrading to 1.4 from 1.3, and I want to start using dojo.cache! :(

Changed 10 years ago by Michael Bannister

Attachment: query_with_plus.html added

comment:7 in reply to:  6 Changed 10 years ago by Michael Bannister

Patch attached, including additions to test case. I would really appreciate feedback as this is my first ever contribution like this :)

Changed 10 years ago by Karl Tiedt

Attachment: query_infix.patch added

possible fix for 10651 (renamed to .patch)

comment:8 Changed 10 years ago by Karl Tiedt

I replaced your patch with one that was named .patch (trac will colorize it then) (both .patch and .diff are treated specially)

comment:9 Changed 10 years ago by bill

Mike, could you file a CLA so we can look at your patch?

comment:10 in reply to:  9 Changed 10 years ago by Michael Bannister

Replying to bill:

Mike, could you file a CLA so we can look at your patch?

Done (by email) - I meant to say that I'd do this today as I don't have a printer at home!

Michael

comment:11 Changed 10 years ago by bill

Summary: [regression]dojo.query not working for attribute selector that includes a tilda (~) character[regression] [patch] [cla] dojo.query not working for attribute selector that includes a tilda (~) character

Cool, thanks!

Changed 9 years ago by Michael Bannister

Attachment: query_infix2.patch added

possible fix for 10651 (corrected)

comment:12 Changed 9 years ago by Michael Bannister

I discovered that Safari/Chrome? and Firefox delivered slightly different results when my RegExp? hit the end-of-string match: Safari/Chrome? passed undefined to the String.replace callback function whereas Firefox gave ""... so I was getting 'undefined' tacked onto simple selectors!

Corrected patch submitted.

comment:13 Changed 9 years ago by James Burke

Milestone: tbd1.6
Owner: changed from alex to James Burke

comment:14 Changed 9 years ago by bill

Milestone: 1.6future

(sadly) punting seemingly abandoned ticket and meta tickets to future

comment:15 Changed 8 years ago by bill

Owner: changed from James Burke to Kris Zyp

comment:16 Changed 8 years ago by bill

Description: modified (diff)
Summary: [regression] [patch] [cla] dojo.query not working for attribute selector that includes a tilda (~) character[regression] [patch] [cla] dojo.query not working for attribute selector that includes a tilde (~) character

comment:17 Changed 8 years ago by ben hockey

sounds related to #7479

comment:18 Changed 8 years ago by ben hockey

Priority: highlow

comment:19 Changed 8 years ago by bill

Milestone: future1.8
Owner: changed from Kris Zyp to bill
Status: newassigned

Michael's patch fixes the bug, so I'm going to check it in.

comment:20 Changed 8 years ago by bill

Resolution: fixed
Status: assignedclosed

In [27952]:

Fix to not apply spacing normalization inside of [ ], thanks michaelbannister!, fixes #10651 !strict.

comment:21 Changed 7 years ago by Colin Snover

In [30033]:

Backport [29124], [27952], and [27961] to 1.7. According to the original changesets, this fixes #14877, #14876, #10651, #11189. !strict

comment:22 Changed 7 years ago by Colin Snover

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