Skip to content

Commit bb239fb

Browse files
committed
1 parent 642105f commit bb239fb

File tree

5 files changed

+8
-54
lines changed

5 files changed

+8
-54
lines changed

packages/svelte/src/internal/client/context.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,15 @@ export function getAllContexts() {
101101
* @returns {void}
102102
*/
103103
export function push(props, runes = false, fn) {
104-
var ctx = (component_context = {
104+
component_context = {
105105
p: component_context,
106106
c: null,
107-
d: false,
108107
e: null,
109108
m: false,
110109
s: props,
111110
x: null,
112111
l: null
113-
});
112+
};
114113

115114
if (legacy_mode_flag && !runes) {
116115
component_context.l = {
@@ -121,10 +120,6 @@ export function push(props, runes = false, fn) {
121120
};
122121
}
123122

124-
teardown(() => {
125-
/** @type {ComponentContext} */ (ctx).d = true;
126-
});
127-
128123
if (DEV) {
129124
// component function
130125
component_context.function = fn;

packages/svelte/src/internal/client/reactivity/props.js

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -240,20 +240,19 @@ const spread_props_handler = {
240240
* @returns {any}
241241
*/
242242
export function props(...props) {
243-
let paused = false;
244-
const context = component_context;
243+
let destroyed = false;
245244
if (active_effect) {
246245
(active_effect.transitions ??= []).push({
247246
is_global: true,
248247
in() {
249-
paused = false;
248+
destroyed = false;
250249
},
251250
out(callback) {
252-
paused = true;
251+
destroyed = true;
253252
callback?.();
254253
},
255254
stop() {
256-
paused = true;
255+
destroyed = true;
257256
}
258257
});
259258
}
@@ -269,21 +268,13 @@ export function props(...props) {
269268
return oldProps;
270269
}),
271270
get destroyed() {
272-
return (context?.d ?? false) || paused;
271+
return destroyed;
273272
}
274273
},
275274
spread_props_handler
276275
);
277276
}
278277

279-
/**
280-
* @param {Derived} current_value
281-
* @returns {boolean}
282-
*/
283-
function has_destroyed_component_ctx(current_value) {
284-
return current_value.ctx?.d ?? false;
285-
}
286-
287278
/**
288279
* This function is responsible for synchronizing a possibly bound prop with the inner component state.
289280
* 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) {
417408
return (inner_current_value.v = parent_value);
418409
});
419410

420-
// Ensure we eagerly capture the initial value if it's bindable
421-
if (bindable) {
422-
get(current_value);
423-
}
424-
425411
if (!immutable) current_value.equals = safe_equals;
426412

427413
return function (/** @type {any} */ value, /** @type {boolean} */ mutation) {
@@ -449,20 +435,12 @@ export function prop(props, key, flags, fallback) {
449435
fallback_value = new_value;
450436
}
451437

452-
if (has_destroyed_component_ctx(current_value)) {
453-
return value;
454-
}
455-
456438
untrack(() => get(current_value)); // force a synchronisation immediately
457439
}
458440

459441
return value;
460442
}
461443

462-
if (has_destroyed_component_ctx(current_value)) {
463-
return current_value.v;
464-
}
465-
466444
return get(current_value);
467445
};
468446
}

packages/svelte/src/internal/client/reactivity/sources.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import {
1414
reaction_sources,
1515
check_dirtiness,
1616
untracking,
17-
is_destroying_effect,
1817
push_reaction_value
1918
} from '../runtime.js';
2019
import { equals, safe_equals } from './equality.js';
@@ -38,9 +37,6 @@ import { execute_derived } from './deriveds.js';
3837

3938
export let inspect_effects = new Set();
4039

41-
/** @type {Map<Source, any>} */
42-
export const old_values = new Map();
43-
4440
/**
4541
* @param {Set<any>} v
4642
*/
@@ -160,14 +156,6 @@ export function set(source, value, should_proxy = false) {
160156
*/
161157
export function internal_set(source, value) {
162158
if (!source.equals(value)) {
163-
var old_value = source.v;
164-
165-
if (is_destroying_effect) {
166-
old_values.set(source, value);
167-
} else {
168-
old_values.set(source, old_value);
169-
}
170-
171159
source.v = value;
172160

173161
if (DEV && tracing_mode_flag) {

packages/svelte/src/internal/client/runtime.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
EFFECT_IS_UPDATING
2626
} from './constants.js';
2727
import { flush_tasks } from './dom/task.js';
28-
import { internal_set, old_values } from './reactivity/sources.js';
28+
import { internal_set } from './reactivity/sources.js';
2929
import { destroy_derived_effects, update_derived } from './reactivity/deriveds.js';
3030
import * as e from './errors.js';
3131

@@ -535,7 +535,6 @@ function flush_queued_root_effects() {
535535
var collected_effects = process_effects(root_effects[i]);
536536
flush_queued_effects(collected_effects);
537537
}
538-
old_values.clear();
539538
}
540539
} finally {
541540
is_flushing = false;
@@ -800,10 +799,6 @@ export function get(signal) {
800799
}
801800
}
802801

803-
if (is_destroying_effect && old_values.has(signal)) {
804-
return old_values.get(signal);
805-
}
806-
807802
return signal.v;
808803
}
809804

packages/svelte/src/internal/client/types.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ export type ComponentContext = {
1414
p: null | ComponentContext;
1515
/** context */
1616
c: null | Map<unknown, unknown>;
17-
/** destroyed */
18-
d: boolean;
1917
/** deferred effects */
2018
e: null | Array<{
2119
fn: () => void | (() => void);

0 commit comments

Comments
 (0)