Skip to main content

Bug Tracker

Side navigation

#8120 closed bug (invalid)

Opened February 01, 2011 12:57PM UTC

Closed February 01, 2011 09:33PM UTC

Last modified February 11, 2011 02:55PM UTC

Attribute selectors now require quotations

Reported by: dom@d3r.com Owned by:
Priority: low Milestone: 1.next
Component: selector Version: 1.5
Keywords: Cc:
Blocked by: Blocking:
Description

It appears that some attribute selectors now require quoting around their values. Failure to do so will throw the following error:

"Syntax error, unrecognized expression: {selector}".

Strangely, this fails with the following piece of code:

$("a[href^=/shortlist/]");

requiring a change to

$("a[href^='/shortlist/']");

but not when using:

$("a[href=#]");

I know this isn't a bug, and that now I check it in fact mentions in the documentation that quotes are mandatory, but it should probably be added as a warning into the release notes, or wherever is appropriate, as it is a change from 1.4.4 that will cause upgrade issues for some.

Attachments (0)
Change History (4)

Changed February 01, 2011 03:25PM UTC by rwaldron comment:1

component: unfiledselector
keywords: → needsdocs
priority: undecidedhigh
status: newopen

Changed February 01, 2011 09:33PM UTC by jitter comment:2

keywords: needsdocs
priority: highlow
resolution: → invalid
status: openclosed

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

After checking your report I came to the conclusion that this isn't a bug. Actually the behavior in jQuery 1.4.4 was wrong and has been fixed in 1.5

a[href^=/shortlist/] isn't a valid CSS selector which you can easily verify with this test case

Beside the documentation explicitly stating that "quotes are mandatory" also the selectors documentation warns you with

If you wish to use any of the meta-characters ( such as !"#$%&'()*+,./:;?@[\\]^`{|}~ ) [...] you must escape the character [...]

This list includes the / character.

Changed February 09, 2011 03:30PM UTC by jitter comment:3

#8223 is a duplicate of this ticket.

Changed February 11, 2011 02:55PM UTC by jitter comment:4

#8248 is a duplicate of this ticket.