Skip to content

fix: key in p could fail if p is null #11388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 10, 2024
Merged
2 changes: 1 addition & 1 deletion packages/svelte/src/internal/client/reactivity/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const spread_props_handler = {
has(target, key) {
for (let p of target.props) {
if (is_function(p)) p = p();
if (key in p) return true;
if (p != null && key in p) return true;
}

return false;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<script>
$: x = Object.keys($$restProps).length;
$: y = Object.keys($$props).length;
</script>

{x} {y}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { test } from '../../test';

export default test({
html: '0 0'
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<script>
import Child from './Child.svelte'
</script>

<Child {...undefined} />