Home / File/ SlotElement.js — svelte Source File

SlotElement.js — svelte Source File

Architecture documentation for SlotElement.js, a javascript file in the svelte codebase. 8 imports, 1 dependents.

File javascript Compiler Transformer 8 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  8d43941e_751c_91a3_002a_bb90ddaae0f5["SlotElement.js"]
  0c5c28a7_226d_4e7c_e75e_0853c0a9fc2c["ast.js"]
  8d43941e_751c_91a3_002a_bb90ddaae0f5 --> 0c5c28a7_226d_4e7c_e75e_0853c0a9fc2c
  653284b2_68fd_eee3_0064_918a4c065d4a["is_text_attribute"]
  8d43941e_751c_91a3_002a_bb90ddaae0f5 --> 653284b2_68fd_eee3_0064_918a4c065d4a
  495501a4_a342_6a4d_ac11_e3e2fee8b218["errors.js"]
  8d43941e_751c_91a3_002a_bb90ddaae0f5 --> 495501a4_a342_6a4d_ac11_e3e2fee8b218
  a146f6ac_0088_8736_b6ce_318f9f115170["e"]
  8d43941e_751c_91a3_002a_bb90ddaae0f5 --> a146f6ac_0088_8736_b6ce_318f9f115170
  56a689f9_11c0_cc76_bd60_41bb6dc96475["warnings.js"]
  8d43941e_751c_91a3_002a_bb90ddaae0f5 --> 56a689f9_11c0_cc76_bd60_41bb6dc96475
  3246e0bc_b9fc_f638_5e35_41e8c39a2408["w"]
  8d43941e_751c_91a3_002a_bb90ddaae0f5 --> 3246e0bc_b9fc_f638_5e35_41e8c39a2408
  c4b4ac8d_9914_5ede_1aea_723bf80d2e9b["fragment.js"]
  8d43941e_751c_91a3_002a_bb90ddaae0f5 --> c4b4ac8d_9914_5ede_1aea_723bf80d2e9b
  313d2a82_30ea_3161_3aad_0cc2094979aa["mark_subtree_dynamic"]
  8d43941e_751c_91a3_002a_bb90ddaae0f5 --> 313d2a82_30ea_3161_3aad_0cc2094979aa
  4aa8a188_84d4_0274_ed83_cac0ab1d3572["index.js"]
  4aa8a188_84d4_0274_ed83_cac0ab1d3572 --> 8d43941e_751c_91a3_002a_bb90ddaae0f5
  style 8d43941e_751c_91a3_002a_bb90ddaae0f5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/** @import { AST } from '#compiler' */
/** @import { Context } from '../types' */
import { is_text_attribute } from '../../../utils/ast.js';
import * as e from '../../../errors.js';
import * as w from '../../../warnings.js';
import { mark_subtree_dynamic } from './shared/fragment.js';

/**
 * @param {AST.SlotElement} node
 * @param {Context} context
 */
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

Functions

Frequently Asked Questions

What does SlotElement.js do?
SlotElement.js is a source file in the svelte codebase, written in javascript. It belongs to the Compiler domain, Transformer subdomain.
What functions are defined in SlotElement.js?
SlotElement.js defines 1 function(s): SlotElement.
What does SlotElement.js depend on?
SlotElement.js imports 8 module(s): ast.js, e, errors.js, fragment.js, is_text_attribute, mark_subtree_dynamic, w, warnings.js.
What files import SlotElement.js?
SlotElement.js is imported by 1 file(s): index.js.
Where is SlotElement.js in the architecture?
SlotElement.js is located at packages/svelte/src/compiler/phases/2-analyze/visitors/SlotElement.js (domain: Compiler, subdomain: Transformer, directory: packages/svelte/src/compiler/phases/2-analyze/visitors).

Analyze Your Own Codebase

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

Try Supermodel Free