Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#8120 closed bug (invalid)

Attribute selectors now require quotations

Reported by: dom@… 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.

Change History (4)

comment:1 Changed 9 years ago by Rick Waldron

Component: unfiledselector
Keywords: needsdocs added
Priority: undecidedhigh
Status: newopen

comment:2 Changed 9 years ago by jitter

Keywords: needsdocs removed
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.

comment:3 Changed 9 years ago by jitter

#8223 is a duplicate of this ticket.

comment:4 Changed 9 years ago by jitter

#8248 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.