From bb863c76cbb8d957fa4060aa63902344d3de2011 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Luba=C5=84ski?= Date: Wed, 5 May 2021 15:13:34 +0200 Subject: [PATCH] fix(html): avoid get property before set, memoize property type --- src/template/resolvers/property.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/template/resolvers/property.js b/src/template/resolvers/property.js index f8f56095..90f2cc34 100644 --- a/src/template/resolvers/property.js +++ b/src/template/resolvers/property.js @@ -13,16 +13,14 @@ export default function resolveProperty(attrName, propertyName, isSVG) { return resolveClassList; case "style": return resolveStyleList; - default: + default: { + let isProp = false; return (host, target, value) => { - if ( - !isSVG && - !(target instanceof SVGElement) && - propertyName in target - ) { - if (target[propertyName] !== value) { - target[propertyName] = value; - } + isProp = + isProp || + (!isSVG && !(target instanceof SVGElement) && propertyName in target); + if (isProp) { + target[propertyName] = value; } else if (value === false || value === undefined || value === null) { target.removeAttribute(attrName); } else { @@ -30,5 +28,6 @@ export default function resolveProperty(attrName, propertyName, isSVG) { target.setAttribute(attrName, attrValue); } }; + } } }