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}
*/
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;

@ -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);
};
}

@ -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<Source, any>} */
export const old_values = new Map();
/**
* @param {Set<any>} 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) {

@ -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;
}

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

Loading…
Cancel
Save