joshuataylor / dompdf

Automatically exported from code.google.com/p/dompdf
0 stars 0 forks source link

element:nth-child(n) acts more like element:nth-of-type(n) #537

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The :nth-child() selector should count all elements when determining if an 
element is affected by the selector formula. Even if an element is specified, 
all elements should be counted and the rule is applied only if the specified 
element *and* the selector formula are both satisfied.

For example, if we have the following style:
  #container p:nth-child(2n) { background-color: blue; }

And the following HTML:
  <div id="container">
    <h1>Title</h1>
    <p>This is blue</p>
    <p>This is not blue</p>
  </div>

The first P encountered will be blue because it matches the criterion.

You can see this in action here:
http://eclecticgeek.com/dompdf/debug.php?identifier=f454699ef98f0442209d12949b04
98e3

References:
http://dev.w3.org/csswg/selectors3/#nth-child-pseudo
https://developer.mozilla.org/en-US/docs/CSS/:nth-child
http://www.quirksmode.org/css/nthchild.html
http://css-tricks.com/how-nth-child-works/

Original issue reported on code.google.com by eclecticgeek on 24 Sep 2012 at 3:07

GoogleCodeExporter commented 9 years ago

Original comment by eclecticgeek on 24 May 2013 at 3:00