HtmlAgilityPack.CssSelectors.NetCore
HtmlAgilityPack.CssSelectors.NetCore copied to clipboard
Added *-of-type pseudos
Adds support for *-of-type
pseudo-classes:
-
first-of-type
-
last-of-type
-
nth-of-type(n)
-
nth-last-of-type(n)
-
only-of-type
Resolved conflicts since I first wrote this PR.
Also, fixed a bug in #14 where the nth index was off by one: the n is indexed starting from 1, not 0.
e.g., the behavior in Chrome is for the Test1.html doc in this repo:
document.querySelectorAll('div:nth-of-type(5)')
// NodeList [div#strict-starts-with-tests]
document.querySelectorAll('li:nth-of-type(2)')
// NodeList [li.lv1.active.hover]
See also MDN docs:
:nth-child() takes a single argument that describes a pattern for matching element indices in a list of siblings. Element indices are 1-based.
Als note that NodeExtensionMethods.GetIndexOnParent()
is indexed starting with 0, while the parameter returned to CheckNode()
is indexed starting with 1.