Home / Function/ validate_binding() — svelte Function Reference

validate_binding() — svelte Function Reference

Architecture documentation for the validate_binding() function in utils.js from the svelte codebase.

Function javascript Compiler Transformer calls 2 called by 2

Entity Profile

Dependency Diagram

graph TD
  6922c44b_14fe_b017_d157_304290a82a06["validate_binding()"]
  d04d7971_88df_542d_dd4f_26170ce6f581["utils.js"]
  6922c44b_14fe_b017_d157_304290a82a06 -->|defined in| d04d7971_88df_542d_dd4f_26170ce6f581
  059abfac_6785_3551_13a8_b20c40ff070b["BindDirective()"]
  059abfac_6785_3551_13a8_b20c40ff070b -->|calls| 6922c44b_14fe_b017_d157_304290a82a06
  2b6a1e4d_7060_eb43_d939_71517fa01ad9["build_component()"]
  2b6a1e4d_7060_eb43_d939_71517fa01ad9 -->|calls| 6922c44b_14fe_b017_d157_304290a82a06
  804afe56_25d1_9f41_dafe_adc75e952134["object()"]
  6922c44b_14fe_b017_d157_304290a82a06 -->|calls| 804afe56_25d1_9f41_dafe_adc75e952134
  c8d80c9d_ab6c_13c0_c85e_a9b120f82f45["blockers()"]
  6922c44b_14fe_b017_d157_304290a82a06 -->|calls| c8d80c9d_ab6c_13c0_c85e_a9b120f82f45
  style 6922c44b_14fe_b017_d157_304290a82a06 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/phases/3-transform/client/visitors/shared/utils.js lines 340–374

export function validate_binding(state, binding, expression) {
	if (binding.expression.type === 'SequenceExpression') {
		return;
	}
	// If we are referencing a $store.foo then we don't need to add validation
	const left = object(binding.expression);
	const left_binding = left && state.scope.get(left.name);
	if (left_binding?.kind === 'store_sub') return;

	const loc = locator(binding.start);

	const obj = /** @type {Expression} */ (expression.object);

	state.init.push(
		b.stmt(
			b.call(
				'$.validate_binding',
				b.literal(state.analysis.source.slice(binding.start, binding.end)),
				binding.metadata.expression.blockers(),
				b.thunk(
					state.store_to_invalidate ? b.sequence([b.call('$.mark_store_binding'), obj]) : obj
				),
				b.thunk(
					/** @type {Expression} */ (
						expression.computed
							? expression.property
							: b.literal(/** @type {Identifier} */ (expression.property).name)
					)
				),
				b.literal(loc.line),
				b.literal(loc.column)
			)
		)
	);
}

Domain

Subdomains

Frequently Asked Questions

What does validate_binding() do?
validate_binding() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/3-transform/client/visitors/shared/utils.js.
Where is validate_binding() defined?
validate_binding() is defined in packages/svelte/src/compiler/phases/3-transform/client/visitors/shared/utils.js at line 340.
What does validate_binding() call?
validate_binding() calls 2 function(s): blockers, object.
What calls validate_binding()?
validate_binding() is called by 2 function(s): BindDirective, build_component.

Analyze Your Own Codebase

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

Try Supermodel Free