@@ -17,7 +17,6 @@ import { LEGACY_DERIVED_PROP, LEGACY_PROPS, STATE_SYMBOL } from '#client/constan
1717import { proxy } from '../proxy.js' ;
1818import { capture_store_binding } from './store.js' ;
1919import { legacy_mode_flag } from '../../flags/index.js' ;
20- import { component_context } from '../context.js' ;
2120import { teardown } from './effects.js' ;
2221
2322/**
@@ -161,8 +160,8 @@ export function legacy_rest_props(props, exclude) {
161160 * The proxy handler for spread props. Handles the incoming array of props
162161 * that looks like `() => { dynamic: props }, { static: prop }, ..` and wraps
163162 * them so that the whole thing is passed to the component as the `$$props` argument.
164- * @typedef {Record<string | symbol, unknown> } T
165- * @type {ProxyHandler<{ props: Array<T | (() => T )>, oldProps: T , destroyed: boolean }> }}
163+ * @typedef {Record<string | symbol, unknown> } AnyProps
164+ * @type {ProxyHandler<{ props: Array<AnyProps | (() => AnyProps )>, oldProps: AnyProps , destroyed: boolean }> }}
166165 */
167166const spread_props_handler = {
168167 get ( target , key ) {
@@ -242,13 +241,18 @@ const spread_props_handler = {
242241 */
243242export function spread_props ( ...props ) {
244243 let destroyed = false ;
245- teardown ( ( ) => {
246- destroyed = true ;
247- } ) ;
244+ teardown ( ( ) => ( destroyed = true ) ) ;
248245 return new Proxy (
249246 {
250247 props,
251- oldProps : { } ,
248+ oldProps : untrack ( ( ) => {
249+ const oldProps = { } ;
250+ for ( let p of props ) {
251+ if ( typeof p === 'function' ) p = p ( ) ;
252+ Object . assign ( oldProps , p ) ;
253+ }
254+ return oldProps ;
255+ } ) ,
252256 get destroyed ( ) {
253257 return destroyed ;
254258 }
0 commit comments