Home / Function/ setup_select_synchronization() — svelte Function Reference

setup_select_synchronization() — svelte Function Reference

Architecture documentation for the setup_select_synchronization() function in RegularElement.js from the svelte codebase.

Function javascript Compiler Transformer calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  bfe6ef19_8d05_fa85_483b_09ebcc1130d8["setup_select_synchronization()"]
  4610488f_3cf2_5f73_043e_da0aa9d026fe["RegularElement.js"]
  bfe6ef19_8d05_fa85_483b_09ebcc1130d8 -->|defined in| 4610488f_3cf2_5f73_043e_da0aa9d026fe
  1e3b81f2_cd53_e5a5_0140_a9af38facf99["RegularElement()"]
  1e3b81f2_cd53_e5a5_0140_a9af38facf99 -->|calls| bfe6ef19_8d05_fa85_483b_09ebcc1130d8
  27fded45_bc11_247b_d3fe_94831379f9ed["build_getter()"]
  bfe6ef19_8d05_fa85_483b_09ebcc1130d8 -->|calls| 27fded45_bc11_247b_d3fe_94831379f9ed
  style bfe6ef19_8d05_fa85_483b_09ebcc1130d8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/phases/3-transform/client/visitors/RegularElement.js lines 510–558

function setup_select_synchronization(value_binding, context) {
	if (context.state.analysis.runes) return;

	let bound = value_binding.expression;

	if (bound.type === 'SequenceExpression') {
		return;
	}

	while (bound.type === 'MemberExpression') {
		bound = /** @type {Identifier | MemberExpression} */ (bound.object);
	}

	/** @type {string[]} */
	const names = [];

	for (const [name, refs] of context.state.scope.references) {
		if (
			refs.length > 0 &&
			// prevent infinite loop
			name !== bound.name
		) {
			names.push(name);
		}
	}

	const invalidator = b.call(
		'$.invalidate_inner_signals',
		b.thunk(
			b.block(
				names.map((name) => {
					const serialized = build_getter(b.id(name), context.state);
					return b.stmt(serialized);
				})
			)
		)
	);

	context.state.init.push(
		b.stmt(
			b.call(
				'$.template_effect',
				b.thunk(
					b.block([b.stmt(/** @type {Expression} */ (context.visit(bound))), b.stmt(invalidator)])
				)
			)
		)
	);
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does setup_select_synchronization() do?
setup_select_synchronization() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/3-transform/client/visitors/RegularElement.js.
Where is setup_select_synchronization() defined?
setup_select_synchronization() is defined in packages/svelte/src/compiler/phases/3-transform/client/visitors/RegularElement.js at line 510.
What does setup_select_synchronization() call?
setup_select_synchronization() calls 1 function(s): build_getter.
What calls setup_select_synchronization()?
setup_select_synchronization() is called by 1 function(s): RegularElement.

Analyze Your Own Codebase

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

Try Supermodel Free