cloudflare / cloudflare/lol-html
Allow manipulating attributes while iterating over them
- Dominant language
- Rust
- Stars
- 2.1k
- Forks
- 111
- PR merge metrics
- No merged PRs in 30d
Description
I would like to have a function similar to [Vec::retain_mut](https://doc.rust-lang.org/nightly/std/vec/struct.Vec.html#method.retain_mut) to remove or modify the attributes of an element while iterating over them.
This is currently doable, but involves iterating over the attributes, collecting and cloning their names, potentially cloning the new value, and searching the attribute in the attribute list every time we want to remove or modify an attribute.
The proposed function would make this much more efficient and simpler to implement.
I guess this function would have to be available on StartTag and on Element. I am not quite sure about the naming, but I'd be willing to contribute this.
Contributor guide
Research direction
Start by reading the attribute iteration APIs on StartTag and Element, then compare their behavior with Rust's Vec::retain_mut. Define the callback and naming behavior for removing or modifying attributes, and ensure the API is available on both types with tests covering each operation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100