Home / File/ TransitionDirective.js — svelte Source File

TransitionDirective.js — svelte Source File

Architecture documentation for TransitionDirective.js, a javascript file in the svelte codebase. 4 imports, 1 dependents.

File javascript Compiler Migrator 4 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  42ba314e_c59a_5f97_37c4_16009ba66836["TransitionDirective.js"]
  73865c3c_2786_c9ac_d34f_b51d28b3a29e["constants.js"]
  42ba314e_c59a_5f97_37c4_16009ba66836 --> 73865c3c_2786_c9ac_d34f_b51d28b3a29e
  d04d7971_88df_542d_dd4f_26170ce6f581["utils.js"]
  42ba314e_c59a_5f97_37c4_16009ba66836 --> d04d7971_88df_542d_dd4f_26170ce6f581
  adc3771e_5aef_eddf_fcf6_46eb2c97455a["parse_directive_name"]
  42ba314e_c59a_5f97_37c4_16009ba66836 --> adc3771e_5aef_eddf_fcf6_46eb2c97455a
  95c28355_f14c_c3cd_5a03_d5a53ca255bc["builders"]
  42ba314e_c59a_5f97_37c4_16009ba66836 --> 95c28355_f14c_c3cd_5a03_d5a53ca255bc
  7665e008_f37d_b860_a594_f2539a66af4e["transform-client.js"]
  7665e008_f37d_b860_a594_f2539a66af4e --> 42ba314e_c59a_5f97_37c4_16009ba66836
  style 42ba314e_c59a_5f97_37c4_16009ba66836 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/** @import { Expression } from 'estree' */
/** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types' */
import { TRANSITION_GLOBAL, TRANSITION_IN, TRANSITION_OUT } from '../../../../../constants.js';
import * as b from '#compiler/builders';
import { parse_directive_name } from './shared/utils.js';

/**
 * @param {AST.TransitionDirective} node
 * @param {ComponentContext} context
 */
export function TransitionDirective(node, context) {
	let flags = node.modifiers.includes('global') ? TRANSITION_GLOBAL : 0;
	if (node.intro) flags |= TRANSITION_IN;
	if (node.outro) flags |= TRANSITION_OUT;

	const args = [
		b.literal(flags),
		context.state.node,
		b.thunk(/** @type {Expression} */ (context.visit(parse_directive_name(node.name))))
	];

	if (node.expression) {
		args.push(b.thunk(/** @type {Expression} */ (context.visit(node.expression))));
	}

	// in after_update to ensure it always happens after bind:this
	let statement = b.stmt(b.call('$.transition', ...args));

	if (node.metadata.expression.is_async()) {
		statement = b.stmt(
			b.call(
				'$.run_after_blockers',
				node.metadata.expression.blockers(),
				b.thunk(b.block([statement]))
			)
		);
	}

	context.state.after_update.push(statement);
}

Domain

Subdomains

Frequently Asked Questions

What does TransitionDirective.js do?
TransitionDirective.js is a source file in the svelte codebase, written in javascript. It belongs to the Compiler domain, Migrator subdomain.
What functions are defined in TransitionDirective.js?
TransitionDirective.js defines 1 function(s): TransitionDirective.
What does TransitionDirective.js depend on?
TransitionDirective.js imports 4 module(s): builders, constants.js, parse_directive_name, utils.js.
What files import TransitionDirective.js?
TransitionDirective.js is imported by 1 file(s): transform-client.js.
Where is TransitionDirective.js in the architecture?
TransitionDirective.js is located at packages/svelte/src/compiler/phases/3-transform/client/visitors/TransitionDirective.js (domain: Compiler, subdomain: Migrator, directory: packages/svelte/src/compiler/phases/3-transform/client/visitors).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free