cloudflare / cloudflare/lol-html
Support :empty pseudo class?
- Dominant language
- Rust
- Stars
- 2.1k
- Forks
- 111
- PR merge metrics
- No merged PRs in 30d
Description
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:
```html
Some text
```
Into:
```html
Some text
```
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 (`
`) 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!
Contributor guide
Research direction
Start by locating the Rust CSS selector parsing and matching entry points in lol-html; the issue does not name specific files or tests. Trace how element and text handlers treat empty elements, then verify that :empty is supported and that :not(:empty) distinguishes empty from non-empty elements.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- web-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100