Home / Function/ SlotElement() — svelte Function Reference

SlotElement() — svelte Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  bbde109b_a581_1e5a_6599_6e5a025e1b96["SlotElement()"]
  8d43941e_751c_91a3_002a_bb90ddaae0f5["SlotElement.js"]
  bbde109b_a581_1e5a_6599_6e5a025e1b96 -->|defined in| 8d43941e_751c_91a3_002a_bb90ddaae0f5
  a4db0a74_0200_d688_861a_d6ed266a6728["slot_element_deprecated()"]
  bbde109b_a581_1e5a_6599_6e5a025e1b96 -->|calls| a4db0a74_0200_d688_861a_d6ed266a6728
  313d2a82_30ea_3161_3aad_0cc2094979aa["mark_subtree_dynamic()"]
  bbde109b_a581_1e5a_6599_6e5a025e1b96 -->|calls| 313d2a82_30ea_3161_3aad_0cc2094979aa
  653284b2_68fd_eee3_0064_918a4c065d4a["is_text_attribute()"]
  bbde109b_a581_1e5a_6599_6e5a025e1b96 -->|calls| 653284b2_68fd_eee3_0064_918a4c065d4a
  46e53336_f8b5_72e9_e899_cc4f194cec5b["slot_element_invalid_name()"]
  bbde109b_a581_1e5a_6599_6e5a025e1b96 -->|calls| 46e53336_f8b5_72e9_e899_cc4f194cec5b
  cc92c518_ea60_cfb6_9ba6_680aa6038e7a["slot_element_invalid_name_default()"]
  bbde109b_a581_1e5a_6599_6e5a025e1b96 -->|calls| cc92c518_ea60_cfb6_9ba6_680aa6038e7a
  c65a90f8_6f2d_9376_7c45_213a4d135c0d["slot_element_invalid_attribute()"]
  bbde109b_a581_1e5a_6599_6e5a025e1b96 -->|calls| c65a90f8_6f2d_9376_7c45_213a4d135c0d
  style bbde109b_a581_1e5a_6599_6e5a025e1b96 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/phases/2-analyze/visitors/SlotElement.js lines 12–42

export function SlotElement(node, context) {
	if (context.state.analysis.runes && !context.state.analysis.custom_element) {
		w.slot_element_deprecated(node);
	}

	mark_subtree_dynamic(context.path);

	/** @type {string} */
	let name = 'default';

	for (const attribute of node.attributes) {
		if (attribute.type === 'Attribute') {
			if (attribute.name === 'name') {
				if (!is_text_attribute(attribute)) {
					e.slot_element_invalid_name(attribute);
				}

				name = attribute.value[0].data;
				if (name === 'default') {
					e.slot_element_invalid_name_default(attribute);
				}
			}
		} else if (attribute.type !== 'SpreadAttribute' && attribute.type !== 'LetDirective') {
			e.slot_element_invalid_attribute(attribute);
		}
	}

	context.state.analysis.slot_names.set(name, node);

	context.next();
}

Domain

Subdomains

Frequently Asked Questions

What does SlotElement() do?
SlotElement() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/2-analyze/visitors/SlotElement.js.
Where is SlotElement() defined?
SlotElement() is defined in packages/svelte/src/compiler/phases/2-analyze/visitors/SlotElement.js at line 12.
What does SlotElement() call?
SlotElement() calls 6 function(s): is_text_attribute, mark_subtree_dynamic, slot_element_deprecated, slot_element_invalid_attribute, slot_element_invalid_name, slot_element_invalid_name_default.

Analyze Your Own Codebase

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

Try Supermodel Free