chore: root effects should not have parents (#10950)

* chore: root effects should not have parents

* tune

* oops

* Update packages/svelte/src/internal/client/runtime.js

Co-authored-by: Rich Harris <rich.harris@vercel.com>

---------

Co-authored-by: Rich Harris <rich.harris@vercel.com>
pull/10955/head
Dominic Gannaway 10 months ago committed by GitHub
parent 9a4cd7e8d8
commit cb18f8fbbe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -39,9 +39,10 @@ import { remove } from '../dom/reconciler.js';
* @returns {import('#client').Effect}
*/
function create_effect(type, fn, sync, init = true) {
var is_root = (type & ROOT_EFFECT) !== 0;
/** @type {import('#client').Effect} */
const effect = {
parent: current_effect,
var effect = {
parent: is_root ? null : current_effect,
dom: null,
deps: null,
f: type | DIRTY,
@ -58,7 +59,7 @@ function create_effect(type, fn, sync, init = true) {
effect.l = current_effect.l + 1;
}
if (current_reaction !== null) {
if (current_reaction !== null && !is_root) {
if (current_reaction.effects === null) {
current_reaction.effects = [effect];
} else {
@ -68,7 +69,7 @@ function create_effect(type, fn, sync, init = true) {
if (init) {
if (sync) {
const previously_flushing_effect = is_flushing_effect;
var previously_flushing_effect = is_flushing_effect;
try {
set_is_flushing_effect(true);

@ -360,12 +360,7 @@ export function remove_reactions(signal, start_index) {
export function destroy_children(signal) {
if (signal.effects) {
for (var i = 0; i < signal.effects.length; i += 1) {
var effect = signal.effects[i];
// TODO ideally root effects would be parentless
if ((effect.f & ROOT_EFFECT) === 0) {
destroy_effect(effect);
}
destroy_effect(signal.effects[i]);
}
signal.effects = null;
}

Loading…
Cancel
Save