From bb239fb965e6f6ce45f8a25db105a6a3f2a5dbcd Mon Sep 17 00:00:00 2001 From: Matei-Paul Trandafir Date: Thu, 12 Jun 2025 21:50:08 +0300 Subject: [PATCH] Revert #15469 --- .../svelte/src/internal/client/context.js | 9 ++---- .../src/internal/client/reactivity/props.js | 32 +++---------------- .../src/internal/client/reactivity/sources.js | 12 ------- .../svelte/src/internal/client/runtime.js | 7 +--- .../svelte/src/internal/client/types.d.ts | 2 -- 5 files changed, 8 insertions(+), 54 deletions(-) diff --git a/packages/svelte/src/internal/client/context.js b/packages/svelte/src/internal/client/context.js index 7c7213b7a2..f381c62d3a 100644 --- a/packages/svelte/src/internal/client/context.js +++ b/packages/svelte/src/internal/client/context.js @@ -101,16 +101,15 @@ export function getAllContexts() { * @returns {void} */ export function push(props, runes = false, fn) { - var ctx = (component_context = { + component_context = { p: component_context, c: null, - d: false, e: null, m: false, s: props, x: null, l: null - }); + }; if (legacy_mode_flag && !runes) { component_context.l = { @@ -121,10 +120,6 @@ export function push(props, runes = false, fn) { }; } - teardown(() => { - /** @type {ComponentContext} */ (ctx).d = true; - }); - if (DEV) { // component function component_context.function = fn; diff --git a/packages/svelte/src/internal/client/reactivity/props.js b/packages/svelte/src/internal/client/reactivity/props.js index 14c91017c1..125647c44b 100644 --- a/packages/svelte/src/internal/client/reactivity/props.js +++ b/packages/svelte/src/internal/client/reactivity/props.js @@ -240,20 +240,19 @@ const spread_props_handler = { * @returns {any} */ export function props(...props) { - let paused = false; - const context = component_context; + let destroyed = false; if (active_effect) { (active_effect.transitions ??= []).push({ is_global: true, in() { - paused = false; + destroyed = false; }, out(callback) { - paused = true; + destroyed = true; callback?.(); }, stop() { - paused = true; + destroyed = true; } }); } @@ -269,21 +268,13 @@ export function props(...props) { return oldProps; }), get destroyed() { - return (context?.d ?? false) || paused; + return destroyed; } }, spread_props_handler ); } -/** - * @param {Derived} current_value - * @returns {boolean} - */ -function has_destroyed_component_ctx(current_value) { - return current_value.ctx?.d ?? false; -} - /** * This function is responsible for synchronizing a possibly bound prop with the inner component state. * It is used whenever the compiler sees that the component writes to the prop, or when it has a default prop_value. @@ -417,11 +408,6 @@ export function prop(props, key, flags, fallback) { return (inner_current_value.v = parent_value); }); - // Ensure we eagerly capture the initial value if it's bindable - if (bindable) { - get(current_value); - } - if (!immutable) current_value.equals = safe_equals; return function (/** @type {any} */ value, /** @type {boolean} */ mutation) { @@ -449,20 +435,12 @@ export function prop(props, key, flags, fallback) { fallback_value = new_value; } - if (has_destroyed_component_ctx(current_value)) { - return value; - } - untrack(() => get(current_value)); // force a synchronisation immediately } return value; } - if (has_destroyed_component_ctx(current_value)) { - return current_value.v; - } - return get(current_value); }; } diff --git a/packages/svelte/src/internal/client/reactivity/sources.js b/packages/svelte/src/internal/client/reactivity/sources.js index 40a3e4e77f..111e8ca7a2 100644 --- a/packages/svelte/src/internal/client/reactivity/sources.js +++ b/packages/svelte/src/internal/client/reactivity/sources.js @@ -14,7 +14,6 @@ import { reaction_sources, check_dirtiness, untracking, - is_destroying_effect, push_reaction_value } from '../runtime.js'; import { equals, safe_equals } from './equality.js'; @@ -38,9 +37,6 @@ import { execute_derived } from './deriveds.js'; export let inspect_effects = new Set(); -/** @type {Map} */ -export const old_values = new Map(); - /** * @param {Set} v */ @@ -160,14 +156,6 @@ export function set(source, value, should_proxy = false) { */ export function internal_set(source, value) { if (!source.equals(value)) { - var old_value = source.v; - - if (is_destroying_effect) { - old_values.set(source, value); - } else { - old_values.set(source, old_value); - } - source.v = value; if (DEV && tracing_mode_flag) { diff --git a/packages/svelte/src/internal/client/runtime.js b/packages/svelte/src/internal/client/runtime.js index 9544060959..237a7a3c99 100644 --- a/packages/svelte/src/internal/client/runtime.js +++ b/packages/svelte/src/internal/client/runtime.js @@ -25,7 +25,7 @@ import { EFFECT_IS_UPDATING } from './constants.js'; import { flush_tasks } from './dom/task.js'; -import { internal_set, old_values } from './reactivity/sources.js'; +import { internal_set } from './reactivity/sources.js'; import { destroy_derived_effects, update_derived } from './reactivity/deriveds.js'; import * as e from './errors.js'; @@ -535,7 +535,6 @@ function flush_queued_root_effects() { var collected_effects = process_effects(root_effects[i]); flush_queued_effects(collected_effects); } - old_values.clear(); } } finally { is_flushing = false; @@ -800,10 +799,6 @@ export function get(signal) { } } - if (is_destroying_effect && old_values.has(signal)) { - return old_values.get(signal); - } - return signal.v; } diff --git a/packages/svelte/src/internal/client/types.d.ts b/packages/svelte/src/internal/client/types.d.ts index 9703c2aac1..a3156b14dd 100644 --- a/packages/svelte/src/internal/client/types.d.ts +++ b/packages/svelte/src/internal/client/types.d.ts @@ -14,8 +14,6 @@ export type ComponentContext = { p: null | ComponentContext; /** context */ c: null | Map; - /** destroyed */ - d: boolean; /** deferred effects */ e: null | Array<{ fn: () => void | (() => void);