Home / Function/ build_attr_class() — svelte Function Reference

build_attr_class() — svelte Function Reference

Architecture documentation for the build_attr_class() function in element.js from the svelte codebase.

Function javascript Compiler Transformer calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  2efbc29a_f2d9_3c09_add9_6804350010a0["build_attr_class()"]
  b25fbb61_695c_e699_cbac_73059624d603["element.js"]
  2efbc29a_f2d9_3c09_add9_6804350010a0 -->|defined in| b25fbb61_695c_e699_cbac_73059624d603
  17370b4c_df64_f183_35da_1de383ea4963["build_element_attributes()"]
  17370b4c_df64_f183_35da_1de383ea4963 -->|calls| 2efbc29a_f2d9_3c09_add9_6804350010a0
  804afe56_25d1_9f41_dafe_adc75e952134["object()"]
  2efbc29a_f2d9_3c09_add9_6804350010a0 -->|calls| 804afe56_25d1_9f41_dafe_adc75e952134
  style 2efbc29a_f2d9_3c09_add9_6804350010a0 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/phases/3-transform/server/visitors/shared/element.js lines 483–513

function build_attr_class(class_directives, expression, context, hash, transform) {
	/** @type {ObjectExpression | undefined} */
	let directives;

	if (class_directives.length) {
		directives = b.object(
			class_directives.map((directive) =>
				b.prop(
					'init',
					b.literal(directive.name),
					transform(
						/** @type {Expression} */ (context.visit(directive.expression, context.state)),
						directive.metadata.expression
					)
				)
			)
		);
	}

	let css_hash;

	if (hash) {
		if (expression.type === 'Literal' && typeof expression.value === 'string') {
			expression.value = (expression.value + ' ' + hash).trim();
		} else {
			css_hash = b.literal(hash);
		}
	}

	return b.call('$.attr_class', expression, css_hash, directives);
}

Domain

Subdomains

Calls

Frequently Asked Questions

What does build_attr_class() do?
build_attr_class() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/3-transform/server/visitors/shared/element.js.
Where is build_attr_class() defined?
build_attr_class() is defined in packages/svelte/src/compiler/phases/3-transform/server/visitors/shared/element.js at line 483.
What does build_attr_class() call?
build_attr_class() calls 1 function(s): object.
What calls build_attr_class()?
build_attr_class() is called by 1 function(s): build_element_attributes.

Analyze Your Own Codebase

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

Try Supermodel Free