Skip to content

Commit f219c79

Browse files
fsoft72dummdidumm
andauthored
fix: check for falsy values in spread (#11388)
--------- Co-authored-by: Simon H <[email protected]> Co-authored-by: Simon Holthausen <[email protected]>
1 parent f70c037 commit f219c79

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

packages/svelte/src/internal/client/reactivity/props.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ const spread_props_handler = {
169169
has(target, key) {
170170
for (let p of target.props) {
171171
if (is_function(p)) p = p();
172-
if (key in p) return true;
172+
if (p != null && key in p) return true;
173173
}
174174

175175
return false;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<script>
2+
$: x = Object.keys($$restProps).length;
3+
$: y = Object.keys($$props).length;
4+
</script>
5+
6+
{x} {y}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { test } from '../../test';
2+
3+
export default test({
4+
html: '0 0'
5+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<script>
2+
import Child from './Child.svelte'
3+
</script>
4+
5+
<Child {...undefined} />

0 commit comments

Comments
 (0)