Modify ↓
Ticket #13070 (closed bug: fixed)
filter()/is() does not work correctly with attribute equals selector which contains special characters
| Reported by: | caikanxp@… | Owned by: | gibson042 |
|---|---|---|---|
| Priority: | high | Milestone: | 1.9 |
| Component: | selector | Version: | 1.8.3 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
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>
Change History
comment:2 Changed 5 months ago by gibson042
- Owner set to gibson042
- Priority changed from undecided to high
- Status changed from new to assigned
- Component changed from unfiled to selector
- Milestone changed from None to 1.9
comment:3 Changed 5 months ago by Richard Gibson
- Status changed from assigned to closed
- Resolution set to fixed
Fix #13070: better unescaping logic in Sizzle
Changeset: 00bbbe207555d3aa9d7716bb9fc6d4e4f4bcbf1e
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
Note: See
TracTickets for help on using
tickets.

Here is the jsFiddle test case: http://jsfiddle.net/zR7xQ/