validate_slot_attribute() — svelte Function Reference
Architecture documentation for the validate_slot_attribute() function in attribute.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD c3969ef3_0f9b_1699_e3b6_75b4a9916c7d["validate_slot_attribute()"] 32df1fa2_adf7_5122_0b02_c399ea508ae0["attribute.js"] c3969ef3_0f9b_1699_e3b6_75b4a9916c7d -->|defined in| 32df1fa2_adf7_5122_0b02_c399ea508ae0 aa41b09d_e55c_ecda_de33_e201a39ef960["SvelteFragment()"] aa41b09d_e55c_ecda_de33_e201a39ef960 -->|calls| c3969ef3_0f9b_1699_e3b6_75b4a9916c7d c2e078e7_8b02_06d2_5983_59b1af376889["visit_component()"] c2e078e7_8b02_06d2_5983_59b1af376889 -->|calls| c3969ef3_0f9b_1699_e3b6_75b4a9916c7d 8b731563_0657_df8d_6a4b_cd33990e2ed2["validate_element()"] 8b731563_0657_df8d_6a4b_cd33990e2ed2 -->|calls| c3969ef3_0f9b_1699_e3b6_75b4a9916c7d 653284b2_68fd_eee3_0064_918a4c065d4a["is_text_attribute()"] c3969ef3_0f9b_1699_e3b6_75b4a9916c7d -->|calls| 653284b2_68fd_eee3_0064_918a4c065d4a 1b59eeca_63bb_fb39_c178_3d01bfc062a3["slot_attribute_invalid()"] c3969ef3_0f9b_1699_e3b6_75b4a9916c7d -->|calls| 1b59eeca_63bb_fb39_c178_3d01bfc062a3 76437ce7_73fa_a7f2_397a_1ddd381e8282["is_custom_element_node()"] c3969ef3_0f9b_1699_e3b6_75b4a9916c7d -->|calls| 76437ce7_73fa_a7f2_397a_1ddd381e8282 37f3ccad_cdba_ea36_1170_1a81548e93d5["slot_attribute_invalid_placement()"] c3969ef3_0f9b_1699_e3b6_75b4a9916c7d -->|calls| 37f3ccad_cdba_ea36_1170_1a81548e93d5 c01687aa_76eb_156a_a60e_1d0b0148559a["slot_attribute_duplicate()"] c3969ef3_0f9b_1699_e3b6_75b4a9916c7d -->|calls| c01687aa_76eb_156a_a60e_1d0b0148559a cc4b6b67_a7c5_54c0_8d2f_ba667d331710["slot_default_duplicate()"] c3969ef3_0f9b_1699_e3b6_75b4a9916c7d -->|calls| cc4b6b67_a7c5_54c0_8d2f_ba667d331710 style c3969ef3_0f9b_1699_e3b6_75b4a9916c7d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/compiler/phases/2-analyze/visitors/shared/attribute.js lines 56–125
export function validate_slot_attribute(context, attribute, is_component = false) {
const parent = context.path.at(-2);
let owner = undefined;
if (parent?.type === 'SnippetBlock') {
if (!is_text_attribute(attribute)) {
e.slot_attribute_invalid(attribute);
}
return;
}
let i = context.path.length;
while (i--) {
const ancestor = context.path[i];
if (
!owner &&
(ancestor.type === 'Component' ||
ancestor.type === 'SvelteComponent' ||
ancestor.type === 'SvelteSelf' ||
ancestor.type === 'SvelteElement' ||
(ancestor.type === 'RegularElement' && is_custom_element_node(ancestor)))
) {
owner = ancestor;
}
}
if (owner) {
if (
owner.type === 'Component' ||
owner.type === 'SvelteComponent' ||
owner.type === 'SvelteSelf'
) {
if (owner !== parent) {
if (!is_component) {
e.slot_attribute_invalid_placement(attribute);
}
} else {
if (!is_text_attribute(attribute)) {
e.slot_attribute_invalid(attribute);
}
const name = attribute.value[0].data;
if (context.state.component_slots.has(name)) {
e.slot_attribute_duplicate(attribute, name, owner.name);
}
context.state.component_slots.add(name);
if (name === 'default') {
for (const node of owner.fragment.nodes) {
if (node.type === 'Text' && regex_only_whitespaces.test(node.data)) {
continue;
}
if (node.type === 'RegularElement' || node.type === 'SvelteFragment') {
if (node.attributes.some((a) => a.type === 'Attribute' && a.name === 'slot')) {
continue;
}
}
e.slot_default_duplicate(node);
}
}
}
}
} else if (!is_component) {
e.slot_attribute_invalid_placement(attribute);
}
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does validate_slot_attribute() do?
validate_slot_attribute() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/2-analyze/visitors/shared/attribute.js.
Where is validate_slot_attribute() defined?
validate_slot_attribute() is defined in packages/svelte/src/compiler/phases/2-analyze/visitors/shared/attribute.js at line 56.
What does validate_slot_attribute() call?
validate_slot_attribute() calls 6 function(s): is_custom_element_node, is_text_attribute, slot_attribute_duplicate, slot_attribute_invalid, slot_attribute_invalid_placement, slot_default_duplicate.
What calls validate_slot_attribute()?
validate_slot_attribute() is called by 3 function(s): SvelteFragment, validate_element, visit_component.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free