Skip to content

Commit

Permalink
fix(html): avoid get property before set, memoize property type
Browse files Browse the repository at this point in the history
  • Loading branch information
smalluban committed May 5, 2021
1 parent c62d5df commit bb863c7
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/template/resolvers/property.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,21 @@ 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 {
const attrValue = value === true ? "" : String(value);
target.setAttribute(attrName, attrValue);
}
};
}
}
}

0 comments on commit bb863c7

Please sign in to comment.