Home / Function/ attributes() — svelte Function Reference

attributes() — svelte Function Reference

Architecture documentation for the attributes() function in index.js from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  64c42a6a_4e9f_ca08_f5f4_a6300195f48a["attributes()"]
  f0404eed_e134_3c7c_7b38_1cb13c71f197["index.js"]
  64c42a6a_4e9f_ca08_f5f4_a6300195f48a -->|defined in| f0404eed_e134_3c7c_7b38_1cb13c71f197
  762e2645_df97_dd47_1f3c_ed224a27b85a["base_element()"]
  762e2645_df97_dd47_1f3c_ed224a27b85a -->|calls| 64c42a6a_4e9f_ca08_f5f4_a6300195f48a
  b7c774b0_a062_49fb_8173_3089fe5dcded["svelte_visitors.Script()"]
  b7c774b0_a062_49fb_8173_3089fe5dcded -->|calls| 64c42a6a_4e9f_ca08_f5f4_a6300195f48a
  5479e7dd_d3ab_b681_86d1_add8144a8582["svelte_visitors.StyleSheet()"]
  5479e7dd_d3ab_b681_86d1_add8144a8582 -->|calls| 64c42a6a_4e9f_ca08_f5f4_a6300195f48a
  bf5d5240_8295_eb9d_761a_40c36ac83580["svelte_visitors.SvelteComponent()"]
  bf5d5240_8295_eb9d_761a_40c36ac83580 -->|calls| 64c42a6a_4e9f_ca08_f5f4_a6300195f48a
  db7bcfe6_94b2_81da_e75d_1ea0ae9d514f["svelte_visitors.SvelteElement()"]
  db7bcfe6_94b2_81da_e75d_1ea0ae9d514f -->|calls| 64c42a6a_4e9f_ca08_f5f4_a6300195f48a
  style 64c42a6a_4e9f_ca08_f5f4_a6300195f48a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/print/index.js lines 64–92

function attributes(attributes, context) {
	if (attributes.length === 0) {
		return false;
	}

	// Measure total width of all attributes when rendered inline
	const child_context = context.new();

	for (const attribute of attributes) {
		child_context.write(' ');
		child_context.visit(attribute);
	}

	const multiline = child_context.measure() > LINE_BREAK_THRESHOLD;

	if (multiline) {
		context.indent();
		for (const attribute of attributes) {
			context.newline();
			context.visit(attribute);
		}
		context.dedent();
		context.newline();
	} else {
		context.append(child_context);
	}

	return multiline;
}

Domain

Subdomains

Frequently Asked Questions

What does attributes() do?
attributes() is a function in the svelte codebase, defined in packages/svelte/src/compiler/print/index.js.
Where is attributes() defined?
attributes() is defined in packages/svelte/src/compiler/print/index.js at line 64.
What calls attributes()?
attributes() is called by 5 function(s): base_element, svelte_visitors.Script, svelte_visitors.StyleSheet, svelte_visitors.SvelteComponent, svelte_visitors.SvelteElement.

Analyze Your Own Codebase

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

Try Supermodel Free