#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 )
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)
Change History (26)
Changed 11 years ago by
comment:1 Changed 11 years ago by
Component: | Core → Query |
---|---|
Owner: | changed from anonymous to alex |
comment:2 Changed 11 years ago by
Cc: | Karl Tiedt added |
---|
comment:3 Changed 11 years ago by
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 11 years ago by
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 11 years ago by
Does this work?
var infixSpaceRe = /"[^"]*"|'[^']*'|n\+\d|([^ ])?([>~+])([^ =])?/g;
comment:6 follow-up: 7 Changed 11 years ago by
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 11 years ago by
Attachment: | query_with_plus.html added |
---|
comment:7 Changed 11 years ago by
Patch attached, including additions to test case. I would really appreciate feedback as this is my first ever contribution like this :)
Changed 11 years ago by
Attachment: | query_infix.patch added |
---|
possible fix for 10651 (renamed to .patch)
comment:8 Changed 11 years ago by
I replaced your patch with one that was named .patch (trac will colorize it then) (both .patch and .diff are treated specially)
comment:9 follow-up: 10 Changed 11 years ago by
Mike, could you file a CLA so we can look at your patch?
comment:10 Changed 11 years ago by
comment:11 Changed 11 years ago by
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!
comment:12 Changed 11 years ago by
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 11 years ago by
Milestone: | tbd → 1.6 |
---|---|
Owner: | changed from alex to James Burke |
comment:14 Changed 10 years ago by
Milestone: | 1.6 → future |
---|
(sadly) punting seemingly abandoned ticket and meta tickets to future
comment:15 Changed 9 years ago by
Owner: | changed from James Burke to Kris Zyp |
---|
comment:16 Changed 9 years ago by
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:18 Changed 9 years ago by
Priority: | high → low |
---|
comment:19 Changed 9 years ago by
Milestone: | future → 1.8 |
---|---|
Owner: | changed from Kris Zyp to bill |
Status: | new → assigned |
Michael's patch fixes the bug, so I'm going to check it in.
comment:22 Changed 8 years ago by
Milestone: | 1.8 → 1.7.5 |
---|
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