Home / Function/ validate_attribute() — svelte Function Reference

validate_attribute() — svelte Function Reference

Architecture documentation for the validate_attribute() function in attribute.js from the svelte codebase.

Function javascript Compiler Transformer calls 3 called by 2

Entity Profile

Dependency Diagram

graph TD
  c3dd29c6_654d_d119_4318_e8151ff6da98["validate_attribute()"]
  32df1fa2_adf7_5122_0b02_c399ea508ae0["attribute.js"]
  c3dd29c6_654d_d119_4318_e8151ff6da98 -->|defined in| 32df1fa2_adf7_5122_0b02_c399ea508ae0
  c2e078e7_8b02_06d2_5983_59b1af376889["visit_component()"]
  c2e078e7_8b02_06d2_5983_59b1af376889 -->|calls| c3dd29c6_654d_d119_4318_e8151ff6da98
  8b731563_0657_df8d_6a4b_cd33990e2ed2["validate_element()"]
  8b731563_0657_df8d_6a4b_cd33990e2ed2 -->|calls| c3dd29c6_654d_d119_4318_e8151ff6da98
  76437ce7_73fa_a7f2_397a_1ddd381e8282["is_custom_element_node()"]
  c3dd29c6_654d_d119_4318_e8151ff6da98 -->|calls| 76437ce7_73fa_a7f2_397a_1ddd381e8282
  126dc1ac_00f7_d4b9_a79f_c785e1db9eb5["attribute_quoted()"]
  c3dd29c6_654d_d119_4318_e8151ff6da98 -->|calls| 126dc1ac_00f7_d4b9_a79f_c785e1db9eb5
  1be7467c_b1bc_4aa0_a1fa_e88569dcedcf["attribute_unquoted_sequence()"]
  c3dd29c6_654d_d119_4318_e8151ff6da98 -->|calls| 1be7467c_b1bc_4aa0_a1fa_e88569dcedcf
  style c3dd29c6_654d_d119_4318_e8151ff6da98 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/phases/2-analyze/visitors/shared/attribute.js lines 27–49

export function validate_attribute(attribute, parent) {
	if (
		Array.isArray(attribute.value) &&
		attribute.value.length === 1 &&
		attribute.value[0].type === 'ExpressionTag' &&
		(parent.type === 'Component' ||
			parent.type === 'SvelteComponent' ||
			parent.type === 'SvelteSelf' ||
			(parent.type === 'RegularElement' && is_custom_element_node(parent)))
	) {
		w.attribute_quoted(attribute);
	}

	if (attribute.value === true || !Array.isArray(attribute.value) || attribute.value.length === 1) {
		return;
	}

	const is_quoted = attribute.value.at(-1)?.end !== attribute.end;

	if (!is_quoted) {
		e.attribute_unquoted_sequence(attribute);
	}
}

Domain

Subdomains

Frequently Asked Questions

What does validate_attribute() do?
validate_attribute() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/2-analyze/visitors/shared/attribute.js.
Where is validate_attribute() defined?
validate_attribute() is defined in packages/svelte/src/compiler/phases/2-analyze/visitors/shared/attribute.js at line 27.
What does validate_attribute() call?
validate_attribute() calls 3 function(s): attribute_quoted, attribute_unquoted_sequence, is_custom_element_node.
What calls validate_attribute()?
validate_attribute() is called by 2 function(s): validate_element, visit_component.

Analyze Your Own Codebase

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

Try Supermodel Free