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: |
Description
I think this is a bug with the internal
isSimpleRegExp 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.