Skip to content

Commit fcb003f

Browse files
authored
Optimization for aria-/data- attr detection (#3948)
1 parent 9035b54 commit fcb003f

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/diff/props.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,16 @@ export function setProperty(dom, name, value, oldValue, isSvg) {
126126
} catch (e) {}
127127
}
128128

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

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

0 commit comments

Comments
 (0)