Skip to main content

Bug Tracker

Side navigation

#1727 closed bug (fixed)

Opened September 25, 2007 10:51AM UTC

Closed November 17, 2007 12:39AM UTC

:nth-child(An+B) incompatibility with CSS3

Reported by: amachang Owned by: davidserduke
Priority: major Milestone: 1.2.2
Component: core Version: 1.2.1
Keywords: Cc:
Blocked by: Blocking:
Description

Code:

<style> ul > li { display: none } </style>
<script src="jquery.js"></script>
<script>$(function() {

    $('ul > li:nth-child(3n+1)').css('display','block');

})</script>
<style>

    ul > li:nth-child(3n+1) { display: block } 

</style>

<ul>
 <li>CSS3 select this element.</li>
 <li>jQuery select this element.</li>
 <li></li>
 <li>CSS3 select this element.</li>
 <li>jQuery select this element.</li>
<ul>

Patch:

Index: selector.js
===================================================================
--- selector.js (revision 3472)
+++ selector.js (working copy)
@@ -372,7 +372,7 @@
                                        if ( first == 1 ) {
                                                if ( last == 0 || node.nodeIndex == last )
                                                        add = true;
-                                       } else if ( (node.nodeIndex + last) % first == 0 )
+                                       } else if ( (node.nodeIndex - last) % first == 0 )
                                                add = true;
 
                                        if ( add ^ not )
Attachments (2)
  • 1727.diff (1.4 KB) - added by davidserduke November 06, 2007 07:27PM UTC.

    patch

  • jquery_test.html (1.5 KB) - added by davidserduke November 06, 2007 07:28PM UTC.

    test cases

Change History (3)

Changed November 06, 2007 07:26PM UTC by davidserduke comment:1

Going over the way the selector works in CSS3 here

http://www.w3.org/TR/css3-selectors/#nth-child-pseudo

I noticed a few other issues. Negative numbers didn't work and (n+1) was giving (1) instead of (n). Those are fixed in the patch as well.

Changed November 15, 2007 01:50PM UTC by brandon comment:2

need: ReviewCommit
owner: → davidserduke

Changed November 17, 2007 12:39AM UTC by davidserduke comment:3

resolution: → fixed
status: newclosed

Fixed in [3836].