Bug Tracker

Ticket #3796 (closed bug: fixed)

Opened 6 years ago

Last modified 6 years ago

POS slector related bug

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

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*)\))?

Change History

comment:1 Changed 6 years ago by balazs.endresz

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*)\))?(?:[^:-]|$)/;

comment:2 Changed 6 years ago by john

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

Fixed here:  http://github.com/jeresig/sizzle/commit/03f3935c1191b3bc23f138fb64ee65deb8c2797c Will land in the next merge with jQuery. Thanks for the tip!

comment:3 Changed 6 years ago by john

Changed the final selector portion to a positive lookahead, which resolved the final issue.  http://github.com/jeresig/sizzle/commit/0d00986ec0e07cf2b295649679b57bda4532f28b

Note: See TracTickets for help on using tickets.