Skip to main content

Bug Tracker

Side navigation

#7596 closed bug (fixed)

Opened November 22, 2010 05:06PM UTC

Closed July 03, 2012 02:26AM UTC

xpath selector attribute name with brackets [] fails

Reported by: jcctmg@gmail.com Owned by:
Priority: high Milestone: 1.8
Component: selector Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:
Description

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/

Attachments (0)
Change History (20)

Changed November 22, 2010 05:49PM UTC by rwaldron comment:1

description: {{{ \ \ 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/ \ \ }}}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/ \

Changed November 22, 2010 06:13PM UTC by jitter comment:2

_comment0: Updated [http://jsfiddle.net/jitter/LB6u3/ 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 browser which don't support qSA so I guess Sizzle problem.1290450184771216
_comment1: Updated [http://jsfiddle.net/jitter/LB6u3/ 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 so I guess it's a Sizzle problem.1290450295354967
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.

Changed December 01, 2010 03:17PM UTC by zevero comment:3

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> 

Changed December 01, 2010 03:30PM UTC by zevero comment:4

I have made a testcase:[http://jsfiddle.net/FqTuK/]

Please Run with jQuery 1.4.4 and jQuery 1.4.3

Changed December 01, 2010 03:43PM UTC by zevero comment:5

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

Changed December 01, 2010 03:56PM UTC by zevero comment:6

Workaround! OK

' ' or " " do the job

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

Changed December 01, 2010 04:15PM UTC by anonymous comment:7

According to W3C

escaping with /[ should work, but it DOES NOT

ok ... thats enough comments for today :)

Changed December 01, 2010 11:30PM UTC by jitter comment:8

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.

Changed December 01, 2010 11:30PM UTC by jitter comment:9

Duplicate of #7539.

Changed December 06, 2010 10:35AM UTC by anonymous comment:10

This ticket is not a exactly duplicate of #7539.

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

Changed December 06, 2010 11:24AM UTC by jitter comment:11

resolution: duplicate
status: closedreopened

Changed December 06, 2010 12:17PM UTC by jitter comment:12

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.

Changed December 09, 2010 09:21PM UTC by jitter comment:13

#7741 is a duplicate of this ticket.

Changed January 14, 2011 11:59PM UTC by anonymous comment:14

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

Changed January 15, 2011 12:05AM UTC by ljharb@gmail.com comment:15

Replying to [comment:14 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.

Changed January 19, 2011 11:14PM UTC by ljharb@gmail.com comment:16

Replying to [comment:15 ljharb@…]:

Replying to [comment:14 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 *=.

Changed February 13, 2011 07:19PM UTC by jitter comment:17

#8260 is a duplicate of this ticket.

Changed July 12, 2011 04:20PM UTC by john comment:18

#9014 is a duplicate of this ticket.

Changed July 12, 2011 04:21PM UTC by john comment:19

Confirmed in bug triage.

Changed July 03, 2012 02:26AM UTC by timmywil comment:20

milestone: 1.next1.8
resolution: → fixed
status: openclosed