Skip to main content

Bug Tracker

Side navigation

#8246 closed bug (duplicate)

Opened February 11, 2011 07:22AM UTC

Closed February 11, 2011 01:58PM UTC

Last modified February 11, 2011 01:58PM UTC

Attribute value selectors containing colons now trigger a syntax error

Reported by: kemayo Owned by:
Priority: low Milestone: 1.next
Component: selector Version: 1.5
Keywords: Cc:
Blocked by: Blocking:
Description

Works: $('[foo=bar]')

Syntax error: $('[foo=bar:12]')

This is a regression from jQuery 1.4.4.

Here's it in 1.5: http://jsfiddle.net/Yewzw/

And in 1.4.4: http://jsfiddle.net/RCHFZ/1/

Attachments (0)
Change History (4)

Changed February 11, 2011 07:23AM UTC by anonymous comment:1

I think it's fair that it rejects this, but it *is* a regression.

Changed February 11, 2011 07:25AM UTC by kemayo comment:2

Sorry, the title should have stated "unquoted attribute value selectors". (It works fine if you do [foo="bar:12"].)

Changed February 11, 2011 01:58PM UTC by jitter comment:3

component: unfiledselector
priority: undecidedlow
resolution: → duplicate
status: newclosed

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

This isn't a regression it was a bug in earlier jQuery versions that got fixed.

Try http://jsfiddle.net/jitter/Yewzw/1/ and you will see that [foo=bar:12] isn't a valid CSS selector and neither is it a valid selector in jQuery. You need to fix your code to either quote or espace the attribute value.

The documentation is also pretty clear about these kind of selectors:

http://api.jquery.com/category/selectors/

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

http://api.jquery.com/category/selectors/attribute-selectors/

Attribute values in selector expressions must be surrounded by quotation marks.

http://api.jquery.com/attribute-equals-selector/

Quotes are mandatory.

Changed February 11, 2011 01:58PM UTC by jitter comment:4

Duplicate of #8229.