@@ -361,21 +361,23 @@ export function prop(props, key, flags, fallback) {
361361 // means we can just call `$$props.foo = value` directly
362362 if ( setter ) {
363363 var legacy_parent = props . $$legacy ;
364- return /** @type {() => V } */ ( function ( /** @type {V } */ value , /** @type {boolean } */ mutation ) {
365- if ( arguments . length > 0 ) {
366- // We don't want to notify if the value was mutated and the parent is in runes mode.
367- // In that case the state proxy (if it exists) should take care of the notification.
368- // If the parent is not in runes mode, we need to notify on mutation, too, that the prop
369- // has changed because the parent will not be able to detect the change otherwise.
370- if ( ! runes || ! mutation || legacy_parent || is_store_sub ) {
371- /** @type {Function } */ ( setter ) ( mutation ? getter ( ) : value ) ;
364+ return /** @type {() => V } */ (
365+ function ( /** @type {V } */ value , /** @type {boolean } */ mutation ) {
366+ if ( arguments . length > 0 ) {
367+ // We don't want to notify if the value was mutated and the parent is in runes mode.
368+ // In that case the state proxy (if it exists) should take care of the notification.
369+ // If the parent is not in runes mode, we need to notify on mutation, too, that the prop
370+ // has changed because the parent will not be able to detect the change otherwise.
371+ if ( ! runes || ! mutation || legacy_parent || is_store_sub ) {
372+ /** @type {Function } */ ( setter ) ( mutation ? getter ( ) : value ) ;
373+ }
374+
375+ return value ;
372376 }
373377
374- return value ;
378+ return getter ( ) ;
375379 }
376-
377- return getter ( ) ;
378- } ) ;
380+ ) ;
379381 }
380382
381383 // Either prop is written to, but there's no binding, which means we
@@ -397,30 +399,32 @@ export function prop(props, key, flags, fallback) {
397399 if ( bindable ) get ( d ) ;
398400
399401 var parent_effect = /** @type {Effect } */ ( active_effect ) ;
400-
401- return /** @type {() => V } */ ( function ( /** @type {any } */ value , /** @type {boolean } */ mutation ) {
402- if ( arguments . length > 0 ) {
403- const new_value = mutation ? get ( d ) : runes && bindable ? proxy ( value ) : value ;
404402
405- set ( d , new_value ) ;
406- overridden = true ;
403+ return /** @type {() => V } */ (
404+ function ( /** @type {any } */ value , /** @type {boolean } */ mutation ) {
405+ if ( arguments . length > 0 ) {
406+ const new_value = mutation ? get ( d ) : runes && bindable ? proxy ( value ) : value ;
407+
408+ set ( d , new_value ) ;
409+ overridden = true ;
410+
411+ if ( fallback_value !== undefined ) {
412+ fallback_value = new_value ;
413+ }
407414
408- if ( fallback_value !== undefined ) {
409- fallback_value = new_value ;
415+ return value ;
410416 }
411417
412- return value ;
413- }
418+ // special case — avoid recalculating the derived if we're in a
419+ // teardown function and the prop was overridden locally, or the
420+ // component was already destroyed (this latter part is necessary
421+ // because `bind:this` can read props after the component has
422+ // been destroyed. TODO simplify `bind:this`
423+ if ( ( is_destroying_effect && overridden ) || ( parent_effect . f & DESTROYED ) !== 0 ) {
424+ return d . v ;
425+ }
414426
415- // special case — avoid recalculating the derived if we're in a
416- // teardown function and the prop was overridden locally, or the
417- // component was already destroyed (this latter part is necessary
418- // because `bind:this` can read props after the component has
419- // been destroyed. TODO simplify `bind:this`
420- if ( ( is_destroying_effect && overridden ) || ( parent_effect . f & DESTROYED ) !== 0 ) {
421- return d . v ;
427+ return get ( d ) ;
422428 }
423-
424- return get ( d ) ;
425- } ) ;
429+ ) ;
426430}
0 commit comments