Ticket #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: | ||
| Blocking: | Blocked by: |
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
comment:1 Changed 2 years ago by rwaldron
- Keywords needsdocs added
- Priority changed from undecided to high
- Status changed from new to open
- Component changed from unfiled to selector
comment:2 Changed 2 years ago by jitter
- Keywords needsdocs removed
- Priority changed from high to low
- Status changed from open to closed
- Resolution set to invalid
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.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.
