pull/16140/head
Matei-Paul Trandafir 3 months ago
parent 642105f6ef
commit bb239fb965
No known key found for this signature in database
GPG Key ID: BC96CA77836E14F8

@ -101,16 +101,15 @@ export function getAllContexts() {
* @returns {void} * @returns {void}
*/ */
export function push(props, runes = false, fn) { export function push(props, runes = false, fn) {
var ctx = (component_context = { component_context = {
p: component_context, p: component_context,
c: null, c: null,
d: false,
e: null, e: null,
m: false, m: false,
s: props, s: props,
x: null, x: null,
l: null l: null
}); };
if (legacy_mode_flag && !runes) { if (legacy_mode_flag && !runes) {
component_context.l = { component_context.l = {
@ -121,10 +120,6 @@ export function push(props, runes = false, fn) {
}; };
} }
teardown(() => {
/** @type {ComponentContext} */ (ctx).d = true;
});
if (DEV) { if (DEV) {
// component function // component function
component_context.function = fn; component_context.function = fn;

@ -240,20 +240,19 @@ const spread_props_handler = {
* @returns {any} * @returns {any}
*/ */
export function props(...props) { export function props(...props) {
let paused = false; let destroyed = false;
const context = component_context;
if (active_effect) { if (active_effect) {
(active_effect.transitions ??= []).push({ (active_effect.transitions ??= []).push({
is_global: true, is_global: true,
in() { in() {
paused = false; destroyed = false;
}, },
out(callback) { out(callback) {
paused = true; destroyed = true;
callback?.(); callback?.();
}, },
stop() { stop() {
paused = true; destroyed = true;
} }
}); });
} }
@ -269,21 +268,13 @@ export function props(...props) {
return oldProps; return oldProps;
}), }),
get destroyed() { get destroyed() {
return (context?.d ?? false) || paused; return destroyed;
} }
}, },
spread_props_handler 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. * 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. * 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); 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; if (!immutable) current_value.equals = safe_equals;
return function (/** @type {any} */ value, /** @type {boolean} */ mutation) { return function (/** @type {any} */ value, /** @type {boolean} */ mutation) {
@ -449,20 +435,12 @@ export function prop(props, key, flags, fallback) {
fallback_value = new_value; fallback_value = new_value;
} }
if (has_destroyed_component_ctx(current_value)) {
return value;
}
untrack(() => get(current_value)); // force a synchronisation immediately untrack(() => get(current_value)); // force a synchronisation immediately
} }
return value; return value;
} }
if (has_destroyed_component_ctx(current_value)) {
return current_value.v;
}
return get(current_value); return get(current_value);
}; };
} }

@ -14,7 +14,6 @@ import {
reaction_sources, reaction_sources,
check_dirtiness, check_dirtiness,
untracking, untracking,
is_destroying_effect,
push_reaction_value push_reaction_value
} from '../runtime.js'; } from '../runtime.js';
import { equals, safe_equals } from './equality.js'; import { equals, safe_equals } from './equality.js';
@ -38,9 +37,6 @@ import { execute_derived } from './deriveds.js';
export let inspect_effects = new Set(); export let inspect_effects = new Set();
/** @type {Map<Source, any>} */
export const old_values = new Map();
/** /**
* @param {Set<any>} v * @param {Set<any>} v
*/ */
@ -160,14 +156,6 @@ export function set(source, value, should_proxy = false) {
*/ */
export function internal_set(source, value) { export function internal_set(source, value) {
if (!source.equals(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; source.v = value;
if (DEV && tracing_mode_flag) { if (DEV && tracing_mode_flag) {

@ -25,7 +25,7 @@ import {
EFFECT_IS_UPDATING EFFECT_IS_UPDATING
} from './constants.js'; } from './constants.js';
import { flush_tasks } from './dom/task.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 { destroy_derived_effects, update_derived } from './reactivity/deriveds.js';
import * as e from './errors.js'; import * as e from './errors.js';
@ -535,7 +535,6 @@ function flush_queued_root_effects() {
var collected_effects = process_effects(root_effects[i]); var collected_effects = process_effects(root_effects[i]);
flush_queued_effects(collected_effects); flush_queued_effects(collected_effects);
} }
old_values.clear();
} }
} finally { } finally {
is_flushing = false; 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; return signal.v;
} }

@ -14,8 +14,6 @@ export type ComponentContext = {
p: null | ComponentContext; p: null | ComponentContext;
/** context */ /** context */
c: null | Map<unknown, unknown>; c: null | Map<unknown, unknown>;
/** destroyed */
d: boolean;
/** deferred effects */ /** deferred effects */
e: null | Array<{ e: null | Array<{
fn: () => void | (() => void); fn: () => void | (() => void);

Loading…
Cancel
Save