Bug Tracker

Opened 8 years ago

Closed 8 years ago

#7796 closed bug (worksforme)

Selecting element by attribute value fails when a space exists before closing bracket.

Reported by: dygerati@… Owned by:
Priority: high Milestone: 1.next
Component: selector Version: 1.4.4
Keywords: Cc:
Blocked by: Blocking:

Description

See jsFiddle example: http://jsfiddle.net/marcofucci/rRtAq/

If you try to select an element based on an attribute value, and leave an empty space directly prior to closing bracket, no value will be fetched.

Deletion of the space will remedy the problem.

This may not be considered a bug since adding enclosing quotations around the variable will also solve the issue, which is the proper syntax, but the given code sample works fine on prior versions of jQuery.

Change History (4)

comment:1 in reply to:  description Changed 8 years ago by dygerati@…

Posted incorrect jsFiddle link, here it is: http://jsfiddle.net/Dygerati/bQYhF/

Replying to dygerati@…:

See jsFiddle example: http://jsfiddle.net/marcofucci/rRtAq/

If you try to select an element based on an attribute value, and leave an empty space directly prior to closing bracket, no value will be fetched.

Deletion of the space will remedy the problem.

This may not be considered a bug since adding enclosing quotations around the variable will also solve the issue, which is the proper syntax, but the given code sample works fine on prior versions of jQuery.

comment:2 Changed 8 years ago by jitter

Component: unfiledselector
Milestone: 1.next1.4.5
Priority: undecidedhigh
Status: newopen

Thanks for taking the time to contribute to the jQuery project by writing a bug report.

test case

This is a regression introduced with jQuery 1.4.4 in this Sizzle commit where the regexp is too greedy and includes the whitespace into the match for the attribute value. So input[name=/test ] becomes input[name='test '] instead of input[name='test']

comment:3 Changed 8 years ago by john

Confirmed in bug triage.

comment:4 Changed 8 years ago by timmywil

Resolution: worksforme
Status: openclosed

This does not seem to be a problem in jQuery git. http://jsfiddle.net/timmywil/qwcTA/5/

Note: See TracTickets for help on using tickets.