rename effect.y to effect.ondestroy

pull/10760/head
Rich Harris 2 years ago
parent 313d34223b
commit de21dd6219

@ -175,7 +175,7 @@ export function await_block(anchor_node, input, pending_fn, then_fn, catch_fn) {
block,
false
);
await_effect.y = () => {
await_effect.ondestroy = () => {
let render = current_render;
latest_token = {};
while (render !== null) {

@ -261,7 +261,7 @@ function each(anchor_node, collection, flags, key_fn, render_fn, fallback_fn, re
set_current_hydration_fragment([]);
}
each.y = () => {
each.ondestroy = () => {
const flags = block.f;
const anchor_node = block.a;
const is_controlled = (flags & EACH_IS_CONTROLLED) !== 0;

@ -167,7 +167,7 @@ export function if_block(anchor_node, condition_fn, consequent_fn, alternate_fn)
true
);
block.ae = alternate_effect;
if_effect.y = () => {
if_effect.ondestroy = () => {
if (consequent_dom !== null) {
remove(consequent_dom);
}

@ -122,7 +122,7 @@ export function key_block(anchor_node, key, render_fn) {
// we trigger the effect after.
render();
mounted = true;
key_effect.y = () => {
key_effect.ondestroy = () => {
let render = current_render;
while (render !== null) {
const dom = render.d;

@ -39,7 +39,7 @@ function create_effect(type, fn, sync, block, schedule) {
teardown: null,
w: 0,
ctx: current_component_context,
y: null
ondestroy: null
};
if (current_effect !== null) {
@ -245,10 +245,10 @@ export function render_effect(fn, block = current_block, managed = false, sync =
*/
export function destroy_effect(signal) {
const teardown = signal.teardown;
const destroy = signal.y;
const destroy = signal.ondestroy;
destroy_references(signal);
remove_reactions(signal, 0);
signal.fn = signal.effects = signal.y = signal.ctx = signal.block = signal.deps = null;
signal.fn = signal.effects = signal.ondestroy = signal.ctx = signal.block = signal.deps = null;
set_signal_status(signal, DESTROYED);
if (destroy !== null) {
if (is_array(destroy)) {

@ -40,7 +40,7 @@ export interface Effect extends Reaction {
/** context: The associated component if this signal is an effect/computed */
ctx: null | ComponentContext;
/** destroy: Thing(s) that need destroying */
y: null | (() => void);
ondestroy: null | (() => void);
/** init: The function that we invoke for effects and computeds */
fn: null | (() => void | (() => void)) | ((b: Block, s: Signal) => void | (() => void));
/** value: The latest value for this signal, doubles as the teardown for effects */

@ -1381,7 +1381,7 @@ export function bind_this(element_or_component, update, get_value, get_parts) {
// Add effect teardown (likely causes: if block became false, each item removed, component unmounted).
// In these cases we need to nullify the binding only if we detect that the value is still the same.
// If not, that means that another effect has now taken over the binding.
e.y = () => {
e.ondestroy = () => {
// Defer to the next tick so that all updates can be reconciled first.
// This solves the case where one variable is shared across multiple this-bindings.
effect(() => {
@ -1552,7 +1552,7 @@ export function head(render_fn) {
block,
false
);
head_effect.y = () => {
head_effect.ondestroy = () => {
const current = block.d;
if (current !== null) {
remove(current);
@ -1665,7 +1665,7 @@ export function element(anchor_node, tag_fn, is_svg, render_fn) {
block,
true
);
element_effect.y = () => {
element_effect.ondestroy = () => {
if (element !== null) {
remove(element);
block.d = null;
@ -1778,7 +1778,7 @@ export function component(anchor_node, component_fn, render_fn) {
block,
false
);
component_effect.y = () => {
component_effect.ondestroy = () => {
let render = current_render;
while (render !== null) {
const dom = render.d;
@ -1842,7 +1842,7 @@ export function css_props(anchor, is_html, props, component) {
}
current_props = next_props;
});
effect.y = () => {
effect.ondestroy = () => {
remove(tag);
};
}
@ -1874,7 +1874,7 @@ export function html(dom, get_value, svg) {
html_dom = reconcile_html(dom, value, svg);
}
});
effect.y = () => {
effect.ondestroy = () => {
if (html_dom) {
remove(html_dom);
}

Loading…
Cancel
Save