[selectors] Rewrite :nth-of-type() and co a little better as well.