lol-html icon indicating copy to clipboard operation
lol-html copied to clipboard

Support :empty pseudo class?

Open tmpfs opened this issue 5 years ago • 0 comments

Hi, thanks for this library it is quite impressive and I enjoyed reading the blog post.

I am using it to do some basic rewriting where I need access to the text content of the nodes in order to rewrite. So I want to convert:

<h1>Some text</h1>

Into:

<h1 id="some-text">Some text</h1>

I got it all working by doing two passes once with the selector on text elements, buffering the contents into vectors and then doing a second pass on the elements to rewrite the attributes. But there is one minor issue in that when an element is empty (<h1></h1>) the text handler never fires but the element handler fires (which is expected and in many ways correct as there is no text to parse). I tried amending the selector to include :not(:empty) which in theory would fix the problem but :empty is not a supported pseudo class. Would it be possible to support the :empty pseudo class?

Thanks!

tmpfs avatar Jul 28 '20 01:07 tmpfs