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.47k stars 82 forks source link

HTMLRewriter’s element.setAttribute() method alters the surrounding single quote character #214

Open Febtw opened 6 months ago

Febtw commented 6 months ago

I’m using the element.setAttribute() method within Cloudflare Workers’ HTMLRewriter. When attempting to set attributes for HTML elements using this method, if the attribute value is enclosed in single quotes ('), HTMLRewriter converts it to double quotes ("). This results in attribute values being enclosed in double quotes. Is there any way to keep the original surrounding quotes, after element.setAttribute() sets the attribute?

This issue resembles a similar issue found in cheerio Maintain tag attribute quote characters · Issue #720 · cheeriojs/cheerio · GitHub use single quotes for values that contain double quotes