Skip to content

Commit

Permalink
allow patches to be falsy values
Browse files Browse the repository at this point in the history
  • Loading branch information
deebloo committed Jan 25, 2025
1 parent b648a6b commit de65a2e
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions integration/counter/src/counter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export class CounterElement extends HTMLElement {
}

#update(change: number) {
const value = Number(this.innerHTML.trim());
this.innerHTML = String(value + change);
this.innerHTML = String(Number(this.innerHTML.trim()) + change);
}
}
4 changes: 2 additions & 2 deletions packages/element/src/lib/query-all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ function patchNodes<T extends HTMLElement>(
const newValue = patch[update];
const oldValue = node[update];

if (newValue && newValue !== oldValue) {
node[update] = newValue;
if (newValue !== oldValue) {
Reflect.set(node, update, newValue);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/element/src/lib/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ function patchNode<T extends HTMLElement>(
const newValue = patch[key];
const oldValue = target[key];

if (newValue && newValue !== oldValue) {
target[key] = newValue;
if (newValue !== oldValue) {
Reflect.set(target, key, newValue);
}
}

Expand Down

0 comments on commit de65a2e

Please sign in to comment.