Bug Tracker

Opened 12 years ago

Closed 12 years ago

#3757 closed bug (fixed)

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:

Description

I think this is a bug with the internal isSimple 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 http://github.com/chuyeow/sizzle/commit/0eb905887b7f20533d1d6945d9dc8a58ba0bc7f7 and http://github.com/chuyeow/sizzle/commit/243327d1bcf3f2009e837ec8a8004010887192d2.

Change History (2)

comment:1 Changed 12 years ago by flesler

Component: coreselector
Owner: set to john

comment:2 Changed 12 years ago by john

Resolution: fixed
Status: newclosed
Version: 1.2.6

Fixed in SVN rev [6018].

Note: See TracTickets for help on using tickets.