pull/16270/head
Rich Harris 3 months ago
parent 2a16f17de7
commit b141f60a7f

@ -15,8 +15,6 @@ export const DESTROYED = 1 << 14;
export const EFFECT_RAN = 1 << 15; export const EFFECT_RAN = 1 << 15;
/** 'Transparent' effects do not create a transition boundary */ /** 'Transparent' effects do not create a transition boundary */
export const EFFECT_TRANSPARENT = 1 << 16; export const EFFECT_TRANSPARENT = 1 << 16;
/** Svelte 4 legacy mode props need to be handled with deriveds and be recognized elsewhere, hence the dedicated flag */
export const LEGACY_DERIVED_PROP = 1 << 17;
export const INSPECT_EFFECT = 1 << 18; export const INSPECT_EFFECT = 1 << 18;
export const HEAD_EFFECT = 1 << 19; export const HEAD_EFFECT = 1 << 19;
export const EFFECT_HAS_DERIVED = 1 << 20; export const EFFECT_HAS_DERIVED = 1 << 20;

@ -8,12 +8,11 @@ import {
PROPS_IS_UPDATED PROPS_IS_UPDATED
} from '../../../constants.js'; } from '../../../constants.js';
import { get_descriptor, is_function } from '../../shared/utils.js'; import { get_descriptor, is_function } from '../../shared/utils.js';
import { mutable_source, set, source, update } from './sources.js'; import { set, source, update } from './sources.js';
import { derived, derived_safe_equal } from './deriveds.js'; import { derived, derived_safe_equal } from './deriveds.js';
import { get, captured_signals, untrack } from '../runtime.js'; import { get, untrack } from '../runtime.js';
import { safe_equals } from './equality.js';
import * as e from '../errors.js'; import * as e from '../errors.js';
import { LEGACY_DERIVED_PROP, LEGACY_PROPS, STATE_SYMBOL } from '#client/constants'; import { LEGACY_PROPS, STATE_SYMBOL } from '#client/constants';
import { proxy } from '../proxy.js'; import { proxy } from '../proxy.js';
import { capture_store_binding } from './store.js'; import { capture_store_binding } from './store.js';
import { legacy_mode_flag } from '../../flags/index.js'; import { legacy_mode_flag } from '../../flags/index.js';
@ -326,14 +325,8 @@ export function prop(props, key, flags, fallback) {
return value; return value;
}; };
} else { } else {
// Svelte 4 did not trigger updates when a primitive value was updated to the same value.
// Replicate that behavior through using a derived
var derived_getter = (immutable ? derived : derived_safe_equal)(
() => /** @type {V} */ (props[key])
);
derived_getter.f |= LEGACY_DERIVED_PROP;
getter = () => { getter = () => {
var value = get(derived_getter); var value = /** @type {V} */ (props[key]);
if (value !== undefined) fallback_value = /** @type {V} */ (undefined); if (value !== undefined) fallback_value = /** @type {V} */ (undefined);
return value === undefined ? fallback_value : value; return value === undefined ? fallback_value : value;
}; };

@ -20,7 +20,6 @@ import {
STATE_SYMBOL, STATE_SYMBOL,
BLOCK_EFFECT, BLOCK_EFFECT,
ROOT_EFFECT, ROOT_EFFECT,
LEGACY_DERIVED_PROP,
DISCONNECTED, DISCONNECTED,
EFFECT_IS_UPDATING, EFFECT_IS_UPDATING,
STALE_REACTION STALE_REACTION
@ -863,17 +862,7 @@ export function invalidate_inner_signals(fn) {
var captured = capture_signals(() => untrack(fn)); var captured = capture_signals(() => untrack(fn));
for (var signal of captured) { for (var signal of captured) {
// Go one level up because derived signals created as part of props in legacy mode internal_set(signal, signal.v);
if ((signal.f & LEGACY_DERIVED_PROP) !== 0) {
for (const dep of /** @type {Derived} */ (signal).deps || []) {
if ((dep.f & DERIVED) === 0) {
// Use internal_set instead of set here and below to avoid mutation validation
internal_set(dep, dep.v);
}
}
} else {
internal_set(signal, signal.v);
}
} }
} }

Loading…
Cancel
Save