Skip to main content

Bug Tracker

Side navigation

#3757 closed bug (fixed)

Opened December 29, 2008 03:34PM UTC

Closed December 31, 2008 07:21PM UTC

Incorrect RegExp for determining whether a selector is "simple" (1.3b1-related)

Reported by: chuyeow Owned by: john
Priority: major Milestone: 1.3
Component: selector Version: 1.2.6
Keywords: selector Cc: chuyeow
Blocked by: Blocking:

I think this is a bug with the internal

RegExp that jQuery uses to determine whether a selector is "simple" or not. I think the original intent was for selectors with a comma in them to be not simple.

Try running these:

var isSimple = /^.[^:#\\[\\.]*$/;
isSimple.test('code, #mark'); // false
isSimple.test('#mark, code'); // true, when it should be false

This doesn't cause any problems in jQuery 1.2.6, but it does break in 1.3b1 with Sizzle integrated.

This can be fixed by adding a comma into the RegExp:

isSimple = /^.[^:#\\[\\.,]*$/

This doesn't affect any tests with jQuery 1.2.6 and fixes a bug in 1.3b1 where this works:

jQuery('#ap *').not('code, #mark')

but this breaks with a "match[3] is undefined" error:

jQuery('#ap *').not('#mark, code')

I don't have a patch but I do have my patch and tests on my Github fork of Sizzle at and

Attachments (0)
Change History (2)

Changed December 29, 2008 10:22PM UTC by flesler comment:1

component: coreselector
owner: → john

Changed December 31, 2008 07:21PM UTC by john comment:2

resolution: → fixed
status: newclosed
version: → 1.2.6

Fixed in SVN rev [6018].