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 INERT = 1 << 11;
export const DESTROYED = 1 << 12;
export const ROOT_EFFECT = 1 << 13;
export const ROOT_BLOCK = 0;
export const IF_BLOCK = 1;

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

Loading…
Cancel
Save