Side navigation
#13070 closed bug (fixed)
Opened December 18, 2012 07:36AM UTC
Closed December 21, 2012 02:57AM UTC
filter()/is() does not work correctly with attribute equals selector which contains special characters
| Reported by: | caikanxp@gmail.com | Owned by: | gibson042 |
|---|---|---|---|
| Priority: | high | Milestone: | 1.9 |
| Component: | selector | Version: | 1.8.3 |
| Keywords: | Cc: | ||
| Blocked by: | Blocking: |
Description
filter()/is() does not work correctly with attribute equals selector which contains special characters.
Windows XP SP3.
Chrome 23.
<div></div>
<div></div>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script type="text/javascript">
<!--
var v1 = '\\\\';
var v2 = '"';
var v3 = '\\\\"';
$('div').attr({a1: v1, a2: v2, a3: v3});
var s1 = '[a1="\\\\\\\\"]'; // [a1="\\\\"]
var s2 = '[a2="\\\\""]'; // [a2="\\""]
var s3 = '[a3="\\\\\\\\\\\\""]'; // [a3="\\\\\\""]
var $q = $(s3); // works correctly
console.log($q.length); // 2
console.log($q.filter(s1).length); // 2
console.log($q.is(s1)); // true
console.log($q.filter(s2).length); // 2
console.log($q.is(s2)); // true
// the result is wrong when jQuery contains more then one element
console.log($q.filter(s3).length); // 0, should be 2
console.log($q.is(s3)); // false, should be true
// the result is right when jQuery contains only one element
console.log($q.eq(0).is(s1)); // result: true
console.log($q.eq(0).is(s2)); // result: true
console.log($q.eq(0).is(s3)); // result: true
//-->
</script>
Here is the jsFiddle test case: http://jsfiddle.net/zR7xQ/