Skip to content

Commit 88b288a

Browse files
committed
rename run_transitions to should_intro, add explanatory jsdoc
1 parent 0fdd50d commit 88b288a

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

packages/svelte/src/internal/client/dom/blocks/svelte-element.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
import { remove } from '../reconciler.js';
1111
import { current_block } from '../../runtime.js';
1212
import { is_array } from '../../utils.js';
13-
import { set_run_transitions } from '../../render.js';
13+
import { set_should_intro } from '../../render.js';
1414
import { current_each_item_block, set_current_each_item_block } from './each.js';
1515

1616
/**
@@ -104,7 +104,7 @@ export function element(anchor, get_tag, is_svg, render_fn) {
104104
} else {
105105
// tag is changing — destroy immediately, render contents without intro transitions
106106
destroy_effect(effect);
107-
set_run_transitions(false);
107+
set_should_intro(false);
108108
}
109109
}
110110

@@ -145,7 +145,7 @@ export function element(anchor, get_tag, is_svg, render_fn) {
145145

146146
tag = next_tag;
147147
if (tag) current_tag = tag;
148-
set_run_transitions(true);
148+
set_should_intro(true);
149149

150150
set_current_each_item_block(previous_each_item_block);
151151
}, block);

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { user_effect } from '../../reactivity/effects.js';
33
import { current_effect, untrack } from '../../runtime.js';
44
import { raf } from '../../timing.js';
55
import { loop } from '../../loop.js';
6-
import { run_transitions } from '../../render.js';
6+
import { should_intro } 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';
@@ -208,7 +208,7 @@ export function transition(flags, element, get_fn, get_params) {
208208
// if this is a local transition, we only want to run it if the parent (block) effect's
209209
// parent (branch) effect is where the state change happened. we can determine that by
210210
// looking at whether the branch effect is currently initializing
211-
if (is_intro && run_transitions) {
211+
if (is_intro && should_intro) {
212212
var parent = /** @type {import('#client').Effect} */ (effect.parent);
213213

214214
if (is_global || (parent.f & EFFECT_RAN) !== 0) {

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,16 @@ export const all_registered_events = new Set();
2020
/** @type {Set<(events: Array<string>) => void>} */
2121
export const root_event_handles = new Set();
2222

23-
export let run_transitions = true;
23+
/**
24+
* This is normally true — block effects should run their intro transitions —
25+
* but is false during hydration and mounting (unless `options.intro` is `true`)
26+
* and when creating the children of a `<svelte:element>` that just changed tag
27+
*/
28+
export let should_intro = true;
2429

2530
/** @param {boolean} value */
26-
export function set_run_transitions(value) {
27-
run_transitions = value;
31+
export function set_should_intro(value) {
32+
should_intro = value;
2833
}
2934

3035
/**
@@ -204,7 +209,7 @@ function _mount(Component, options) {
204209
const registered_events = new Set();
205210
const container = options.target;
206211

207-
run_transitions = options.intro ?? false;
212+
should_intro = options.intro ?? false;
208213

209214
/** @type {import('#client').RootBlock} */
210215
const block = {
@@ -250,7 +255,7 @@ function _mount(Component, options) {
250255
const bound_event_listener = handle_event_propagation.bind(null, container);
251256
const bound_document_event_listener = handle_event_propagation.bind(null, document);
252257

253-
run_transitions = true;
258+
should_intro = true;
254259

255260
/** @param {Array<string>} events */
256261
const event_handle = (events) => {

0 commit comments

Comments
 (0)