Content-Length: 317115 | pFad | http://github.com/sveltejs/svelte/pull/16140/commits/3b9fdf982ec95c1a121ef6dd453020c5f1d3d34d

69 fix: ensure #if blocks correctly guard against nullable prop values by rChaoz · Pull Request #16140 · sveltejs/svelte · GitHub
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
Correctly initialize oldProps so it's not null even if it's never read
  • Loading branch information
rChaoz committed Jun 12, 2025
commit 3b9fdf982ec95c1a121ef6dd453020c5f1d3d34d
18 changes: 11 additions & 7 deletions packages/svelte/src/internal/client/reactivity/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { LEGACY_DERIVED_PROP, LEGACY_PROPS, STATE_SYMBOL } from '#client/constan
import { proxy } from '../proxy.js';
import { capture_store_binding } from './store.js';
import { legacy_mode_flag } from '../../flags/index.js';
import { component_context } from '../context.js';
import { teardown } from './effects.js';

/**
Expand Down Expand Up @@ -161,8 +160,8 @@ export function legacy_rest_props(props, exclude) {
* The proxy handler for spread props. Handles the incoming array of props
* that looks like `() => { dynamic: props }, { static: prop }, ..` and wraps
* them so that the whole thing is passed to the component as the `$$props` argument.
* @typedef {Record<string | symbol, unknown>} T
* @type {ProxyHandler<{ props: Array<T | (() => T)>, oldProps: T, destroyed: boolean }>}}
* @typedef {Record<string | symbol, unknown>} AnyProps
* @type {ProxyHandler<{ props: Array<AnyProps | (() => AnyProps)>, oldProps: AnyProps, destroyed: boolean }>}}
*/
const spread_props_handler = {
get(target, key) {
Expand Down Expand Up @@ -242,13 +241,18 @@ const spread_props_handler = {
*/
export function spread_props(...props) {
let destroyed = false;
teardown(() => {
destroyed = true;
});
teardown(() => (destroyed = true));
return new Proxy(
{
props,
oldProps: {},
oldProps: untrack(() => {
const oldProps = {};
for (let p of props) {
if (typeof p === 'function') p = p();
Object.assign(oldProps, p);
}
return oldProps;
}),
get destroyed() {
return destroyed;
}
Expand Down








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/sveltejs/svelte/pull/16140/commits/3b9fdf982ec95c1a121ef6dd453020c5f1d3d34d

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy