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 )
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.