SnippetBlock() — svelte Function Reference
Architecture documentation for the SnippetBlock() function in SnippetBlock.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD 170735b0_d19f_e8fe_cdc9_07ad2d5b7b3a["SnippetBlock()"] e0442a00_296c_5b68_2228_3e947a4a5278["SnippetBlock.js"] 170735b0_d19f_e8fe_cdc9_07ad2d5b7b3a -->|defined in| e0442a00_296c_5b68_2228_3e947a4a5278 ea08cb05_2664_4e93_7551_6103e0cb3a87["validate_block_not_empty()"] 170735b0_d19f_e8fe_cdc9_07ad2d5b7b3a -->|calls| ea08cb05_2664_4e93_7551_6103e0cb3a87 7148e639_69d8_a03d_3f08_bd23f41e718a["validate_opening_tag()"] 170735b0_d19f_e8fe_cdc9_07ad2d5b7b3a -->|calls| 7148e639_69d8_a03d_3f08_bd23f41e718a 33c43290_bcde_29fa_a158_108dc1c41923["snippet_invalid_rest_parameter()"] 170735b0_d19f_e8fe_cdc9_07ad2d5b7b3a -->|calls| 33c43290_bcde_29fa_a158_108dc1c41923 4fe2860f_6c10_b43a_a4dd_aec81cdcaaa2["can_hoist_snippet()"] 170735b0_d19f_e8fe_cdc9_07ad2d5b7b3a -->|calls| 4fe2860f_6c10_b43a_a4dd_aec81cdcaaa2 1eab3ae5_7ba0_8f80_6467_6c63610018fe["snippet_shadowing_prop()"] 170735b0_d19f_e8fe_cdc9_07ad2d5b7b3a -->|calls| 1eab3ae5_7ba0_8f80_6467_6c63610018fe 86a14af8_280b_20c2_e8fc_523e7978992e["snippet_conflict()"] 170735b0_d19f_e8fe_cdc9_07ad2d5b7b3a -->|calls| 86a14af8_280b_20c2_e8fc_523e7978992e style 170735b0_d19f_e8fe_cdc9_07ad2d5b7b3a fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/compiler/phases/2-analyze/visitors/SnippetBlock.js lines 11–75
export function SnippetBlock(node, context) {
context.state.analysis.snippets.add(node);
validate_block_not_empty(node.body, context);
if (context.state.analysis.runes) {
validate_opening_tag(node, context.state, '#');
}
for (const arg of node.parameters) {
if (arg.type === 'RestElement') {
e.snippet_invalid_rest_parameter(arg);
}
}
context.next({ ...context.state, parent_element: null });
const can_hoist =
context.path.length === 1 &&
context.path[0].type === 'Fragment' &&
can_hoist_snippet(context.state.scope, context.state.scopes);
const name = node.expression.name;
if (can_hoist) {
const binding = /** @type {Binding} */ (context.state.scope.get(name));
context.state.analysis.module.scope.declarations.set(name, binding);
}
node.metadata.can_hoist = can_hoist;
const { path } = context;
const parent = path.at(-2);
if (!parent) return;
if (
parent.type === 'Component' &&
parent.attributes.some(
(attribute) =>
(attribute.type === 'Attribute' || attribute.type === 'BindDirective') &&
attribute.name === node.expression.name
)
) {
e.snippet_shadowing_prop(node, node.expression.name);
}
if (node.expression.name !== 'children') return;
if (
parent.type === 'Component' ||
parent.type === 'SvelteComponent' ||
parent.type === 'SvelteSelf'
) {
if (
parent.fragment.nodes.some(
(node) =>
node.type !== 'SnippetBlock' &&
(node.type !== 'Text' || node.data.trim()) &&
node.type !== 'Comment'
)
) {
e.snippet_conflict(node);
}
}
}
Domain
Subdomains
Calls
Source
Frequently Asked Questions
What does SnippetBlock() do?
SnippetBlock() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/2-analyze/visitors/SnippetBlock.js.
Where is SnippetBlock() defined?
SnippetBlock() is defined in packages/svelte/src/compiler/phases/2-analyze/visitors/SnippetBlock.js at line 11.
What does SnippetBlock() call?
SnippetBlock() calls 6 function(s): can_hoist_snippet, snippet_conflict, snippet_invalid_rest_parameter, snippet_shadowing_prop, validate_block_not_empty, validate_opening_tag.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free