You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
even() and odd() are swapped relative to jQuery and the :even/:odd pseudo-classes #145
QueryPath's even() and odd() are the opposite of jQuery's. jQuery 3.5 added .even() and .odd() using zero-based indexes, so .even() keeps positions 0, 2, 4, … QueryPath's even() keeps positions 1, 3, 5, …:
QueryPath's even() and odd() (added in 2.1) predate jQuery's. They count from one, and their DocBlocks say so: "Get the even elements, so counter-intuitively 1, 3, 5, etc." They also disagree with QueryPath's own :even and :odd pseudo-classes, which follow jQuery's zero-based counting (#66): filter(':even') keeps a, c, e.
Options
Swap them to match jQuery and :even/:odd in the next major version. Add an upgrade note. Any code calling either method would silently get the other half of the set, so this can't go in a minor release.
Keep them and point out the difference from filter(':even')/filter(':odd') in the DocBlocks.
Separately, they mishandle text nodes when counting. That is #143.
QueryPath version
main at 4d05c9e. The jQuery values come from jQuery 3.7.1 on jsdom.
Activity