Bug Tracker

Modify

Ticket #3757 (closed bug: fixed)

Opened 4 years ago

Last modified 4 years ago

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
Blocking: Blocked by:

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

comment:1 Changed 4 years ago by flesler

  • Owner set to john
  • Component changed from core to selector

comment:2 Changed 4 years ago by john

  • Status changed from new to closed
  • Version set to 1.2.6
  • Resolution set to fixed

Fixed in SVN rev [6018].

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.