Skip to main content

Bug Tracker

Side navigation

#12968 closed bug (wontfix)

Opened November 27, 2012 09:22AM UTC

Closed November 30, 2012 11:14PM UTC

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

Reported by: stijn.herreman@telenet.be Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: git
Keywords: Cc:
Blocked by: Blocking:
Description

http://jsfiddle.net/JhvqV/

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.

Attachments (0)
Change History (9)

Changed November 27, 2012 02:49PM UTC by dmethvin comment:1

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.

Changed November 27, 2012 03:23PM UTC by gibson042 comment:2

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.

https://github.com/gibson042/sizzle/compare/jquery_12968

Changed November 27, 2012 04:26PM UTC by dmethvin comment:3

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.

Changed November 27, 2012 04:34PM UTC by dmethvin comment:4

Changed November 27, 2012 05:07PM UTC by dmethvin comment:5

Changed November 29, 2012 11:12PM UTC by dmethvin comment:6

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.

Changed November 29, 2012 11:17PM UTC by dmethvin comment:7

Changed November 29, 2012 11:19PM UTC by stijn.herreman@telenet.be comment:8

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.

Changed November 30, 2012 11:14PM UTC by gibson042 comment:9

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.