Skip to main content

Bug Tracker

Side navigation

#3796 closed bug (fixed)

Opened January 06, 2009 06:31PM UTC

Closed January 10, 2009 10:14PM UTC

Last modified January 11, 2009 02:12PM UTC

POS slector related bug

Reported by: balazs.endresz Owned by: john
Priority: major Milestone: 1.3
Component: selector Version: 1.2.6
Keywords: Cc:
Blocked by: Blocking:
Description

$('li').not(':odd:first') fails:

http://groups.google.com/group/jquery-dev/browse_thread/thread/30ea94cfd730ecdb

because the POS regex matches the colon after :odd that would belong to :first. Then without the colon only first remains wich will wrongly match the TAG selector.


Also in the same regex \\(?(\\d*)\\)? can cause problems, I guess. As in #3793 maybe this should be changed to:

(?:\\(?(\\d*)\\))?

Attachments (0)
Change History (3)

Changed January 09, 2009 07:35PM UTC by balazs.endresz comment:1

Inserting a colon near the end of the POS regex will solve this if there aren't any other characters that can possibly follow the expression. (like maybe a ")" ?)

jQuery.expr.match.POS=/:(nth|eq|gt|lt|first|last|even|odd)(?:\\(?(\\d*)\\))?(?:[^:-]|$)/;

Changed January 10, 2009 10:14PM UTC by john comment:2

resolution: → fixed
status: newclosed

Fixed here:

http://github.com/jeresig/sizzle/commit/03f3935c1191b3bc23f138fb64ee65deb8c2797c

Will land in the next merge with jQuery. Thanks for the tip!

Changed January 11, 2009 02:12PM UTC by john comment:3

Changed the final selector portion to a positive lookahead, which resolved the final issue.

http://github.com/jeresig/sizzle/commit/0d00986ec0e07cf2b295649679b57bda4532f28b