Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support :empty pseudo class? #53

Open
tmpfs opened this issue Jul 28, 2020 · 0 comments
Open

Support :empty pseudo class? #53

tmpfs opened this issue Jul 28, 2020 · 0 comments

Comments

@tmpfs
Copy link

tmpfs commented Jul 28, 2020

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant