atifaziz/Hazz

nth-of-type

Opened this issue · 1 comments

Hello there.

I am creating a WYSIWYG editor in Blazor and am using CSS nth-of-type to create a unique selector.
When I run my code I get the following error:

System.FormatException: Unknown functional pseudo 'nth-of-type'. Only nth-child and nth-last-child are supported.

For simple, non-nested elements, like SECTION H1:nth-of-type(1) I can use a work-around

HtmlNode element = null;
if (sel.Contains("nth-of-type"))
{
	var splitty = sel.Split(':');
	var elements = rootNode.QuerySelectorAll(splitty[0]);
	var n = int.Parse(Regex.Match(splitty[1], @"(\d)").Value);
	element = elements[n - 1];
}

But I hit a snag for more complex structures.
Any change of implementing nth-of-type?
You have nth-child, how much work would it be to have nth-of-type?

Thanks

This first needs support in Fizzler (atifaziz/Fizzler#28).