Skip to content

Commit aa64002

Browse files
committed
move effect.ran into the bitmask
1 parent d3ef8a9 commit aa64002

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

packages/svelte/src/internal/client/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const MAYBE_DIRTY = 1 << 10;
1010
export const INERT = 1 << 11;
1111
export const DESTROYED = 1 << 12;
1212
export const IS_ELSEIF = 1 << 13;
13+
export const EFFECT_RAN = 1 << 14;
1314

1415
export const UNINITIALIZED = Symbol();
1516
export const STATE_SYMBOL = Symbol('$state');

packages/svelte/src/internal/client/dom/elements/transitions.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { run_transitions } from '../../render.js';
77
import { is_function } from '../../utils.js';
88
import { current_each_item_block } from '../blocks/each.js';
99
import { TRANSITION_GLOBAL, TRANSITION_IN, TRANSITION_OUT } from '../../../../constants.js';
10+
import { EFFECT_RAN } from '../../constants.js';
1011

1112
/**
1213
* @template T
@@ -207,14 +208,14 @@ export function transition(flags, element, get_fn, get_params) {
207208
// if this is a local transition, we only want to run it if the parent (block) effect's
208209
// parent (branch) effect is where the state change happened. we can determine that by
209210
// looking at whether the branch effect is currently initializing
210-
if (
211-
is_intro &&
212-
run_transitions &&
213-
(is_global || /** @type {import('#client').Effect} */ (effect.parent).ran)
214-
) {
215-
user_effect(() => {
216-
untrack(() => transition.in());
217-
});
211+
if (is_intro && run_transitions) {
212+
var parent = /** @type {import('#client').Effect} */ (effect.parent);
213+
214+
if (is_global || (parent.f & EFFECT_RAN) !== 0) {
215+
user_effect(() => {
216+
untrack(() => transition.in());
217+
});
218+
}
218219
}
219220
}
220221

packages/svelte/src/internal/client/reactivity/effects.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ function create_effect(type, fn, sync, block = current_block, init = true) {
4848
teardown: null,
4949
ctx: current_component_context,
5050
ondestroy: null,
51-
transitions: null,
52-
ran: false
51+
transitions: null
5352
};
5453

5554
if (current_effect !== null) {

packages/svelte/src/internal/client/reactivity/types.d.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,8 @@ export interface Effect extends Reaction {
4949
teardown: null | (() => void);
5050
/** The depth from the root signal, used for ordering render/pre-effects topologically **/
5151
l: number;
52-
53-
// transitions TODO
52+
/** Transition managers created with `$.transition` */
5453
transitions: null | TransitionManager[];
55-
ran: boolean; // TODO fold this into the bitmask
5654
}
5755

5856
export interface ValueDebug<V = unknown> extends Value<V> {

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ import {
2121
DESTROYED,
2222
INERT,
2323
MANAGED,
24-
STATE_SYMBOL
24+
STATE_SYMBOL,
25+
EFFECT_RAN
2526
} from './constants.js';
2627
import { flush_tasks } from './dom/task.js';
2728
import { add_owner } from './dev/ownership.js';
@@ -551,7 +552,7 @@ export function schedule_effect(signal, sync) {
551552
}
552553
}
553554

554-
signal.ran = true;
555+
signal.f |= EFFECT_RAN;
555556
}
556557

557558
/**

0 commit comments

Comments
 (0)