fix $effect.root

blockless
Rich Harris 2 years ago
parent 4e3ddd86ed
commit 3963ff9ec9

@ -10,6 +10,7 @@ export const DIRTY = 1 << 9;
export const MAYBE_DIRTY = 1 << 10; export const MAYBE_DIRTY = 1 << 10;
export const INERT = 1 << 11; export const INERT = 1 << 11;
export const DESTROYED = 1 << 12; export const DESTROYED = 1 << 12;
export const ROOT_EFFECT = 1 << 13;
export const ROOT_BLOCK = 0; export const ROOT_BLOCK = 0;
export const IF_BLOCK = 1; export const IF_BLOCK = 1;

@ -20,7 +20,8 @@ import {
UNOWNED, UNOWNED,
CLEAN, CLEAN,
UNINITIALIZED, UNINITIALIZED,
INERT INERT,
ROOT_EFFECT
} from '../constants.js'; } from '../constants.js';
import { noop } from '../../common.js'; import { noop } from '../../common.js';
@ -83,7 +84,9 @@ function internal_create_effect(type, fn, sync, block, schedule) {
signal.x = current_component_context; signal.x = current_component_context;
if (current_effect !== null) { if (current_effect !== null) {
signal.l = current_effect.l + 1; signal.l = current_effect.l + 1;
push_reference(current_effect, signal); if ((signal.f & ROOT_EFFECT) === 0) {
push_reference(current_effect, signal);
}
} }
if (schedule) { if (schedule) {
schedule_effect(signal, sync); schedule_effect(signal, sync);
@ -140,7 +143,7 @@ export function user_effect(fn) {
* @returns {() => void} * @returns {() => void}
*/ */
export function user_root_effect(fn) { export function user_root_effect(fn) {
const effect = render_effect(fn, current_block, true); const effect = internal_create_effect(RENDER_EFFECT | ROOT_EFFECT, fn, true, current_block, true);
return () => { return () => {
destroy_signal(effect); destroy_signal(effect);
}; };

Loading…
Cancel
Save