Home / Function/ base_element() — svelte Function Reference

base_element() — svelte Function Reference

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

Function javascript Compiler Transformer calls 3 called by 10

Entity Profile

Dependency Diagram

graph TD
  762e2645_df97_dd47_1f3c_ed224a27b85a["base_element()"]
  f0404eed_e134_3c7c_7b38_1cb13c71f197["index.js"]
  762e2645_df97_dd47_1f3c_ed224a27b85a -->|defined in| f0404eed_e134_3c7c_7b38_1cb13c71f197
  80249f3d_6dac_7857_add7_5966103abf8c["svelte_visitors.Component()"]
  80249f3d_6dac_7857_add7_5966103abf8c -->|calls| 762e2645_df97_dd47_1f3c_ed224a27b85a
  e24a0db3_6300_8f06_3997_1fb9f12796e2["svelte_visitors.RegularElement()"]
  e24a0db3_6300_8f06_3997_1fb9f12796e2 -->|calls| 762e2645_df97_dd47_1f3c_ed224a27b85a
  77941d3c_b208_9712_fe0b_619783852f5b["svelte_visitors.SlotElement()"]
  77941d3c_b208_9712_fe0b_619783852f5b -->|calls| 762e2645_df97_dd47_1f3c_ed224a27b85a
  8463a78a_1849_ded1_79a2_2d4bd75f0854["svelte_visitors.SvelteBoundary()"]
  8463a78a_1849_ded1_79a2_2d4bd75f0854 -->|calls| 762e2645_df97_dd47_1f3c_ed224a27b85a
  70b2402f_9cf4_79f6_83f5_9918a81184bb["svelte_visitors.SvelteDocument()"]
  70b2402f_9cf4_79f6_83f5_9918a81184bb -->|calls| 762e2645_df97_dd47_1f3c_ed224a27b85a
  2fa15e9b_57ef_786d_538b_70c8eb0b7e6f["svelte_visitors.SvelteFragment()"]
  2fa15e9b_57ef_786d_538b_70c8eb0b7e6f -->|calls| 762e2645_df97_dd47_1f3c_ed224a27b85a
  8e91e2eb_9b9c_2dd0_03fb_a478499847de["svelte_visitors.SvelteHead()"]
  8e91e2eb_9b9c_2dd0_03fb_a478499847de -->|calls| 762e2645_df97_dd47_1f3c_ed224a27b85a
  6b2a846b_ed92_19c5_d734_533164a4562d["svelte_visitors.SvelteSelf()"]
  6b2a846b_ed92_19c5_d734_533164a4562d -->|calls| 762e2645_df97_dd47_1f3c_ed224a27b85a
  6e7390b1_6c4e_f62e_989f_c07ddd9a5f92["svelte_visitors.SvelteWindow()"]
  6e7390b1_6c4e_f62e_989f_c07ddd9a5f92 -->|calls| 762e2645_df97_dd47_1f3c_ed224a27b85a
  2cbf42a4_b2f1_8533_33a6_75d6c6c5a2cf["svelte_visitors.TitleElement()"]
  2cbf42a4_b2f1_8533_33a6_75d6c6c5a2cf -->|calls| 762e2645_df97_dd47_1f3c_ed224a27b85a
  64c42a6a_4e9f_ca08_f5f4_a6300195f48a["attributes()"]
  762e2645_df97_dd47_1f3c_ed224a27b85a -->|calls| 64c42a6a_4e9f_ca08_f5f4_a6300195f48a
  02a8b5a2_13c5_e5b3_1ed2_617763d0904d["is_void()"]
  762e2645_df97_dd47_1f3c_ed224a27b85a -->|calls| 02a8b5a2_13c5_e5b3_1ed2_617763d0904d
  139b5520_1d69_2489_cf79_ff7f67682f82["block()"]
  762e2645_df97_dd47_1f3c_ed224a27b85a -->|calls| 139b5520_1d69_2489_cf79_ff7f67682f82
  style 762e2645_df97_dd47_1f3c_ed224a27b85a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/print/index.js lines 98–129

function base_element(node, context) {
	const child_context = context.new();

	child_context.write('<' + node.name);

	// Handle special Svelte components/elements that need 'this' attribute
	if (node.type === 'SvelteComponent') {
		child_context.write(' this={');
		child_context.visit(/** @type {AST.SvelteComponent} */ (node).expression);
		child_context.write('}');
	} else if (node.type === 'SvelteElement') {
		child_context.write(' this={');
		child_context.visit(/** @type {AST.SvelteElement} */ (node).tag);
		child_context.write('}');
	}

	const multiline_attributes = attributes(node.attributes, child_context);
	const is_doctype_node = node.name.toLowerCase() === '!doctype';
	const is_self_closing =
		is_void(node.name) || (node.type === 'Component' && node.fragment.nodes.length === 0);

	if (is_doctype_node) child_context.write(`>`);
	else if (is_self_closing) {
		child_context.write(`${multiline_attributes ? '' : ' '}/>`);
	} else {
		child_context.write('>');
		block(child_context, node.fragment, true);
		child_context.write(`</${node.name}>`);
	}

	context.append(child_context);
}

Domain

Subdomains

Frequently Asked Questions

What does base_element() do?
base_element() is a function in the svelte codebase, defined in packages/svelte/src/compiler/print/index.js.
Where is base_element() defined?
base_element() is defined in packages/svelte/src/compiler/print/index.js at line 98.
What does base_element() call?
base_element() calls 3 function(s): attributes, block, is_void.
What calls base_element()?
base_element() is called by 10 function(s): svelte_visitors.Component, svelte_visitors.RegularElement, svelte_visitors.SlotElement, svelte_visitors.SvelteBoundary, svelte_visitors.SvelteDocument, svelte_visitors.SvelteFragment, svelte_visitors.SvelteHead, svelte_visitors.SvelteSelf, and 2 more.

Analyze Your Own Codebase

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

Try Supermodel Free