From 66035adee952928f602207cba91b01d5b15d5526 Mon Sep 17 00:00:00 2001 From: Jason Miller Date: Sat, 25 Mar 2023 13:23:08 -0400 Subject: [PATCH] Optimization for aria-/data- attr detection --- src/diff/props.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/diff/props.js b/src/diff/props.js index 3a589564ea..b0f2f9ee39 100644 --- a/src/diff/props.js +++ b/src/diff/props.js @@ -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);