Side navigation
#12394 closed bug (wontfix)
Opened August 24, 2012 10:50PM UTC
Closed August 29, 2012 05:00PM UTC
Syntax error, unrecognized expression: with .is() contains matching
Reported by: | webmaster@cosmicperl.com | Owned by: | |
---|---|---|---|
Priority: | low | Milestone: | None |
Component: | selector | Version: | 1.8.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
The following no longer works in the latest JQuery:
$('div').is('div[attribute~=multi text]')
Producing the error:
Syntax error, unrecognized expression: div[attribute~=multi text]
It can be fixed by adding speach marks:
$('div').is('div[attribute~="multi text"]')
However, the version without speach marks works with the normal selector:
$('div[attribute~=multi text]')
Which suggests to me this is a bug, and not a new contraint on matching strings that contain spaces.
Attachments (0)
Change History (4)
Changed August 24, 2012 11:36PM UTC by comment:1
Changed August 28, 2012 03:17AM UTC by comment:2
component: | unfiled → selector |
---|---|
priority: | undecided → low |
Please create test cases when possible, it helps us determine whether something is a bug. Here is what I created: http://jsfiddle.net/ns8ft/
Note that the native querySelectorAll throws a syntax error. That tells you the selector is invalid without quotes. When a selector isn't valid we don't guarantee consistent behavior, but I'll leave this open for review to see if we need to take any action.
Changed August 28, 2012 02:17PM UTC by comment:3
status: | new → open |
---|
We insert quotes for attribute values when using .is(),. This was done a while ago to take advantage of matchesSelector whenever possible. We could do the same with the main selection, but in general, the more complex selectors that may contain =
or ]
characters but aren't attribute selectors are seen being passed to the main selection function. Also, it would add another string replace to everyone's selection.
Nevertheless, these may not be good enough reasons to not do it. Either way, this is low priority.
Changed August 29, 2012 05:00PM UTC by comment:4
resolution: | → wontfix |
---|---|
status: | open → closed |
We are now doing slightly stricter selector validation. I'd like to keep it the way it is for now so we can continue to slowly move closer towards the spec.
A couple notes:
1. it has been this way since the introduction of matchesSelector.
2. It has never worked in non-matchesSelector browsers so the results have never been reliable without quotes.
Correction, the version without the speach marks should be acting as logical or and is not the same as "multi text". It does not fix this issue. It's a bug. As per documentation for ~=:
''"This selector matches the test string against each word in the attribute value, where a "word" is defined as a string delimited by whitespace. The selector matches if the test string is exactly equal to any of the words."''