cloudflare / lol-html

Low output latency streaming HTML parser/rewriter with CSS selector-based API
https://crates.io/crates/lol-html
BSD 3-Clause "New" or "Revised" License
1.45k stars 79 forks source link

CSS :has() pseudo-class selector #145

Open kael opened 1 year ago

kael commented 1 year ago

It'd be nice if HTMLRewriter supported the CSS :has() pseudo-class selector.

In my case I'd like to use it for selecting elements which have a child element with specific attributes. For now I need to parse the whole XML tree and then filter upon the array result to check if attributes are there.

sntran commented 2 months ago

That would be nice, but I don't think it is possible with the way streaming parsing works. In order to know if an element has some child element, it has to keep track of the parent element while continuing to parse until the child element. However, by that time, the parent element can no longer be changed, making it rather less useful.