Bug Tracker

Opened 10 years ago

Closed 10 years ago

#12968 closed bug (wontfix)

Selector with syntax error works in FF and IE, not in Chrome.

Reported by: [email protected] Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: git
Keywords: Cc:
Blocked by: Blocking:



This bug happens since at least 1.7.1 and also happens with the git version.

The selector is missing a ) Why does it work in FF and IE? Took me a few minutes to figure out that Chrome wasn't the cause of the issue.

Change History (9)

comment:1 Changed 10 years ago by dmethvin

Looks like the IE and Firefox querySelectorAll don't mind the missing final paren but the Chrome one (rightly) does.

Reduced case showing the issue in IE and Firefox: http://jsfiddle.net/JhvqV/1/

This seems like something we can't fix without serious performance penalties.

comment:2 Changed 10 years ago by gibson042

Eh, maybe moderate penalties; just a support test and adding :not\([^)]*$ to rbuggyQSA (the regex that checks if we can use qSA for a provided selector). But +25 bytes gzipped is probably too heavy an addition for such a small case.


comment:3 Changed 10 years ago by dmethvin

Oh right, since qSA only accepts "simple" selectors there's no worry about nested parens I suppose, although cases like :not([value="(pathological)"] could still pass.

If IE or Firefox gave the wrong answer for this I'd be more worried about a fix, but as it is the only real issue is error diagnostics. Since most devs will test in Chrome at some point nowadays it seems like you'll find the error soon enough.

And of course this should be reported Microsoft and Mozilla. The problem is still present in IE10 BTW.

comment:5 Changed 10 years ago by dmethvin

comment:6 Changed 10 years ago by dmethvin

Based on the discussion in the bugzilla ticket above, I think this is a place where the spec is an ass. Technically, IE and Firefox can justify their behavior per the CSS2 spec. Allowing unmatched parens is just ugly and I'd prefer the Chrome behavior of rejecting the selector. I'm also not sure if Sizzle should "follow the spec" and automagically close everything.

@timmywil and @gibson042, thoughts? I'd be happy closing this wontfix given the ambiguity, rather than trying to pick a winner and being on the losing side in the future.

comment:7 Changed 10 years ago by dmethvin

comment:8 Changed 10 years ago by [email protected]

I've been watching the discussion, I don't understand why the spec would allow such a thing. Since this isn't really a jQuery issue, I suppose a wontfix will do fine. Thank you for creating the browser tickets.

comment:9 Changed 10 years ago by gibson042

Resolution: wontfix
Status: newclosed

I really don't want to support missing parentheses/brackets/quotes, especially when it comes to nesting selectors with :has and :not. Let's just pretend this never happened.

The spec is an ass, indeed.

Note: See TracTickets for help on using tickets.