Bug Tracker

Opened 13 years ago

Closed 11 years ago

#7596 closed bug (fixed)

xpath selector attribute name with brackets [] fails

Reported by: jcctmg@… Owned by:
Priority: high Milestone: 1.8
Component: selector Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:

Description (last modified by Rick Waldron)

I can't select an input which name attribute has [] inside. In normal javascript, it is posible. This works:

document.forms[0]entityOV.arrayOVs[0].dProperty?.value

But in JQuery fails on IE6.0, IE7.0, FF3.0. $("input[name='entityOV.arrayOVs[0].dProperty']").val() and works OK on Chrome 7.0.517.44, FF3.5, IE8.

In this link you can run it online: http://jsfiddle.net/XP34r/

Change History (20)

comment:1 Changed 13 years ago by Rick Waldron

Description: modified (diff)

comment:2 Changed 13 years ago by jitter

Component: unfiledselector
Priority: undecidedhigh
Status: newopen

Updated test case

Thanks for taking the time to contribute to the jQuery project by writing a bug report and providing a testcase!

I can reproduce this only with browsers which don't support qSA (e.g. IE6/7) so I guess it's a Sizzle problem.

Last edited 13 years ago by jitter (previous) (diff)

comment:3 Changed 12 years ago by zevero

I can reproduce it on FF 3.6.12 and Chrome 8.0.552.210 beta on Ubuntu:

<select name="event[maschine_id]"></select>
<script type="text/javascript" >
$(function(){
s = $('select[name=event[maschine_id]]');
s.remove(); //does not work in jQuery 1.4.4 but works on 1.4.2
});
</script> 

comment:4 Changed 12 years ago by zevero

I have made a testcase:http://jsfiddle.net/FqTuK/
Please Run with jQuery 1.4.4 and jQuery 1.4.3

comment:5 Changed 12 years ago by zevero

Escaping with / or / / does not work either :(

comment:6 Changed 12 years ago by zevero

Workaround! OK ' ' or " " do the job

Still there has been a change from 1.4.3 to 1.4.4 Not OK

comment:7 Changed 12 years ago by anonymous

According to W3C

escaping with /[ should work, but it DOES NOT

ok ... thats enough comments for today :)

comment:8 Changed 12 years ago by jitter

Milestone: 1.51.4.5
Resolution: duplicate
Status: openclosed

In jQuery 1.4.4 the quoting of the attribute value in an attribute selector is mandatory (check on api.jquery.com). And when adding quotes all of the test you posted work.

There is a ticket open for variation where the attribute value is unquoted but all offending meta-characters are escaped.

comment:9 Changed 12 years ago by jitter

Duplicate of #7539.

comment:10 Changed 12 years ago by anonymous

This ticket is not a exactly duplicate of #7539.

This is about IE6-7, FF3.0. And the other affects IE8.

comment:11 Changed 12 years ago by jitter

Resolution: duplicate
Status: closedreopened

comment:12 Changed 12 years ago by jitter

Status: reopenedopen

@anonymous thanks. Nice catch. Looks like I got distracted by the comments zevero made on this ticket which where more related to #7539 .

To get to the bottom of this I made a new reduced test case

As I originally already had determined in my first comment to this report

I can reproduce this only with browsers which don't support qSA (e.g. IE6/7) so I guess it's a Sizzle problem.

And this holds true. The error is caused by a bad regex match in Sizzle on this line where the CLASS regex incorrectly matches.

comment:13 Changed 12 years ago by jitter

#7741 is a duplicate of this ticket.

comment:14 Changed 12 years ago by anonymous

I think this is related - http://jsfiddle.net/v6yJw/ in latest Safari on Mac.

comment:15 in reply to:  14 ; Changed 12 years ago by ljharb@…

Replying to anonymous:

I think this is related - http://jsfiddle.net/v6yJw/ in latest Safari on Mac.

Forgot to include my email, and to note that in jQuery 1.2.6 it passes, but as of 1.3.2 it fails.

comment:16 in reply to:  15 Changed 12 years ago by ljharb@…

Replying to ljharb@…:

Replying to anonymous:

I think this is related - http://jsfiddle.net/v6yJw/ in latest Safari on Mac.

Forgot to include my email, and to note that in jQuery 1.2.6 it passes, but as of 1.3.2 it fails.

Never mind that JSFiddle test - I reread http://api.jquery.com/attribute-contains-word-selector/ and apparently ~= requires that the word be delimited by whitespace, and I'm thinking of *=.

comment:17 Changed 12 years ago by jitter

#8260 is a duplicate of this ticket.

comment:18 Changed 12 years ago by john

#9014 is a duplicate of this ticket.

comment:19 Changed 12 years ago by john

Confirmed in bug triage.

comment:20 Changed 11 years ago by Timmy Willison

Milestone: 1.next1.8
Resolution: fixed
Status: openclosed
Note: See TracTickets for help on using tickets.