Problem with .find and attribute selector when attribute have escaped special character
Test Case:
- <!DOCTYPE html>
- <html>
- <head>
- <script src="http://code.jquery.com/jquery-latest.js"></script>
- </head>
- <body>
- <div id="MyDiv">
- <input name="NS$MYFIELD" />
- </div>
- <script>
- var x = jQuery("#MyDiv");
- alert(jQuery("input[name=NS\\$MYFIELD]").length) //1;
- alert(x.find("input[name=NS\\$MYFIELD]").length) //0;
- </script>
- </body>
- </html>
Firebugging it:Stack: find() > Sizzle() > Sizzle() > filter() >
ATTR()
3284 return result == null ?
3285 type === "!=" :
3286 type === "=" ?
3287 value === check :
3288 type === "*=" ?
3289 value.indexOf(check) >= 0 :
3290 type === "~=" ?
3291 (" " + value + " ").indexOf(check) >= 0 :
3292 !check ?
3293 value && result !== false :
3294 type === "!=" ?
3295 value !== check :
3296 type === "^=" ?
3297 value.indexOf(check) === 0 :
3298 type === "$=" ?
3299 value.substr(value.length - check.length) === check :
3300 type === "|=" ?
3301 value === check || value.substr(0, check.length + 1) === check + "-" :
3302 false;
check !=
value as
check has escaped $ character