Bug Tracker

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#8246 closed bug (duplicate)

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/

Change History (4)

comment:1 Changed 9 years ago by anonymous

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

comment:2 Changed 9 years ago by kemayo

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

comment:3 Changed 9 years ago by jitter

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.

comment:4 Changed 9 years ago by jitter

Duplicate of #8229.

Note: See TracTickets for help on using tickets.