Closed
Description
Description
Escaped selectors for attributes don't work using "find()", but they work using "$()".
I would understand if they never worked, but I assumed "find()" and "$()" were doing the same thing...
As a workaround I'm quoting the value, but it's surprising.
Updated to jQuery 3.4.1 a few minutes ago.
Link to test case
https://jsbin.com/cabimotovu/edit?js,console
var selector = '[data-id=' + $.escapeSelector('0_some_$id') + ']';
console.log($(selector).length);
console.log($('html').find(selector).length);
Output:
0
"error"
"Error: Syntax error, unrecognized expression: [data-id=\30 _some_\$id]
at Function.Sizzle.error (https://code.jquery.com/jquery-git.js:1534:8)
at Sizzle.tokenize (https://code.jquery.com/jquery-git.js:2190:11)
at Function.Sizzle [as find] (https://code.jquery.com/jquery-git.js:807:15)
at jQuery.fn.init.find (https://code.jquery.com/jquery-git.js:2871:11)
at qawicop.js:5:48
at https://static.jsbin.com/js/prod/runner-4.1.7.min.js:1:13924
at https://static.jsbin.com/js/prod/runner-4.1.7.min.js:1:10866"