Skip to content

Commit

Permalink
fix(core): fix boolean props being parsed as empty strings
Browse files Browse the repository at this point in the history
  • Loading branch information
lingbopro committed Dec 14, 2024
1 parent 91053a1 commit 132848c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/core/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ export function useElement<ComponentClass extends HTMLElement, Props extends Ele
exposeProperties(this);
for (const name in props) {
const oldProp = this.getAttribute(name);
props[name] = oldProp ?? config.props[name];
let oldPropParsed = parseType(oldProp, config.props[name]);
if (typeof props[name] === 'boolean' && oldProp === '') {
oldPropParsed = true;
}
props[name] = oldPropParsed ?? config.props[name];
createProperty(this, name);
if (props[name] !== config.props[name]) {
nonDefaultProps.push(name);
Expand Down

0 comments on commit 132848c

Please sign in to comment.