Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization for aria-/data- attr detection #3948

Merged
merged 1 commit into from
Mar 27, 2023
Merged
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
14 changes: 7 additions & 7 deletions src/diff/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,16 @@ export function setProperty(dom, name, value, oldValue, isSvg) {
} catch (e) {}
}

// ARIA-attributes have a different notion of boolean values.
// The value `false` is different from the attribute not
// existing on the DOM, so we can't remove it. For non-boolean
// ARIA-attributes we could treat false as a removal, but the
// amount of exceptions would cost us too many bytes. On top of
// that other VDOM frameworks also always stringify `false`.
// aria- and data- attributes have no boolean representation.
// A `false` value is different from the attribute not being
// present, so we can't remove it. For non-boolean aria
// attributes we could treat false as a removal, but the
// amount of exceptions would cost too many bytes. On top of
// that other frameworks generally stringify `false`.

if (typeof value === 'function') {
// never serialize functions as attribute values
} else if (value != null && (value !== false || name.indexOf('-') != -1)) {
} else if (value != null && (value !== false || name[4] === '-')) {
dom.setAttribute(name, value);
} else {
dom.removeAttribute(name);
Expand Down