Skip to main content

Bug Tracker

Side navigation

#6328 closed bug (worksforme)

Opened March 21, 2010 06:24PM UTC

Closed November 10, 2010 12:19AM UTC

Attribute selector with escaped character doesn't work when used with a context

Reported by: slaren Owned by:
Priority: undecided Milestone:
Component: selector Version: 1.4.2
Keywords: Cc:
Blocked by: Blocking:
Description

When filtering by attribute no results are returned if a "[" escaped character is used in conjunction with a context. No errors are reported by jQuery either.

This can be reproduced with the following code (tested with Firefox 3.6):

<html>
<head>
<script src="jquery-1.4.2.min.js" type="text/javascript"></script>
<script>
$(function()
{
    var ctx = $("#mydiv");
    
    // outputs "1: test[0]"
    $("select[name^=test]", ctx).each(function() { console.log("1: " + $(this).attr("name")) });
    
    // no output
    $("select[name^=test\\\\[]", ctx).each(function() { console.log("2: " + $(this).attr("name")) });
    
    // outputs "3: test[0]"
    $("select[name^=test\\\\[]").each(function() { console.log("3: " + $(this).attr("name")) });
});    
</script>
</head>
<body>
    <div id="mydiv">
        <select name="test[0]"></select>
    </div>
</body>
</html>
Attachments (0)
Change History (2)

Changed April 07, 2010 07:22AM UTC by shoty comment:1

When using a selector and specify the context, or directly using .find, the selector indeed doesn't work with escaped \\\\[ \\\\]

Doesn't work:

jQuery('input[name="f\\\\[first_name\\\\]"]','#main_form');
jQuery('#main_form').find('input[name="f\\\\[first_name\\\\]"]');

The following works:

jQuery('input[name="f[first_name]"]','#main_form');
jQuery('#main_form').find('input[name="f[first_name]"]');

This one works also (but the context is not used and matches from whole document)

jQuery('input[name="f\\\\[first_name\\\\]"]')

My question is if this is a bug in the current version and will be updated or this is how it should work?

Changed November 10, 2010 12:19AM UTC by dmethvin comment:2

priority: → undecided
resolution: → worksforme
status: newclosed