Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/api/attributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,18 @@ function getAttr(

if (Object.hasOwn(elem.attribs, name)) {
// Get the (decoded) attribute
return !xmlMode && rboolean.test(name) ? name : elem.attribs[name];
// For boolean attributes, return the attribute name if the value is empty
// or equals the attribute name (standard boolean normalization).
// If the attribute has a non-standard value (e.g., hidden="until-found"),
// return the actual value.
if (!xmlMode && rboolean.test(name)) {
const value = elem.attribs[name];
if (value === '' || value === name) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Normalize boolean values case-insensitively

For parsed HTML such as <input checked="CHECKED">, boolean attributes whose value is the attribute name in a different case are still standard boolean syntax, but this strict comparison now treats them as custom values and returns "CHECKED" instead of preserving Cheerio's normalized "checked" behavior. Since rboolean already matches names case-insensitively, this should compare the value to the attribute name case-insensitively before falling through to return the raw value.

Useful? React with 👍 / 👎.

return name;
}
return value;
}
return elem.attribs[name];
}

// Mimic the DOM and return text content as value for `option's`
Expand Down
Loading