Skip to main content

Bug Tracker

Side navigation

#7796 closed bug (worksforme)

Opened December 16, 2010 10:08PM UTC

Closed October 07, 2011 03:39PM UTC

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

Reported by: dygerati@gmail.com 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.

Attachments (0)
Change History (4)

Changed December 16, 2010 10:13PM UTC by dygerati@gmail.com comment:1

Posted incorrect jsFiddle link, here it is:

http://jsfiddle.net/Dygerati/bQYhF/

Replying to [ticket:7796 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.

Changed December 17, 2010 12:12AM UTC by jitter comment:2

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']

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

Confirmed in bug triage.

Changed October 07, 2011 03:39PM UTC by timmywil comment:4

resolution: → worksforme
status: openclosed

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