8000 fix: ensure #if blocks correctly guard against nullable prop values by rChaoz · Pull Request #16140 · sveltejs/svelte · GitHub
[go: up one dir, main page]

Skip to content

fix: ensure #if blocks correctly guard against nullable prop values #16140

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

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
format
  • Loading branch information
rChaoz committed Jun 12, 2025
commit 144d3ccf63fe4dbe9efb84754acb4198e8f09e7f
21 changes: 16 additions & 5 deletions packages/svelte/src/internal/client/reactivity/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export function legacy_rest_props(props, exclude) {
*/
const spread_props_handler = {
get(target, key) {
if (target.destroyed && key in target.oldProps) return target.oldProps[key]
if (target.destroyed && key in target.oldProps) return target.oldProps[key];
let i = target.props.length;
while (i--) {
let p = target.props[i];
Expand All @@ -181,7 +181,7 @@ const spread_props_handler = {
if (is_function(p)) p = p();
const desc = get_descriptor(p, key);
if (desc && desc.set) {
desc.set(target.oldProps[key] = value);
desc.set((target.oldProps[key] = value));
return true;
}
}
Expand Down Expand Up @@ -241,9 +241,20 @@ const spread_props_handler = {
* @returns {any}
*/
export function spread_props(...props) {
let destroyed = false
teardown(() => { destroyed = true })
return new Proxy({ props, oldProps: {}, get destroyed() { return destroyed } }, spread_props_handler);
let destroyed = false;
teardown(() => {
destroyed = true;
});
return new Proxy(
{
props,
oldProps: {},
get destroyed() {
return destroyed;
}
},
spread_props_handler
);
}

/**
Expand Down
0