infer_namespace() — svelte Function Reference
Architecture documentation for the infer_namespace() function in utils.js from the svelte codebase.
Entity Profile
Dependency Diagram
graph TD 19ba44b1_ed7b_aeee_985f_f1c151bf7e44["infer_namespace()"] f3fad5a9_6b91_ed4f_9331_7f9fc18491c3["utils.js"] 19ba44b1_ed7b_aeee_985f_f1c151bf7e44 -->|defined in| f3fad5a9_6b91_ed4f_9331_7f9fc18491c3 0236de7e_7608_f21c_040b_e454b977a608["Fragment()"] 0236de7e_7608_f21c_040b_e454b977a608 -->|calls| 19ba44b1_ed7b_aeee_985f_f1c151bf7e44 018cf13b_00c1_1002_de36_76e71d0a0a5e["Fragment()"] 018cf13b_00c1_1002_de36_76e71d0a0a5e -->|calls| 19ba44b1_ed7b_aeee_985f_f1c151bf7e44 06f8b738_4399_59d6_de49_05b18c457206["check_nodes_for_namespace()"] 19ba44b1_ed7b_aeee_985f_f1c151bf7e44 -->|calls| 06f8b738_4399_59d6_de49_05b18c457206 style 19ba44b1_ed7b_aeee_985f_f1c151bf7e44 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
packages/svelte/src/compiler/phases/3-transform/utils.js lines 313–359
export function infer_namespace(namespace, parent, nodes) {
if (parent.type === 'RegularElement' && parent.name === 'foreignObject') {
return 'html';
}
if (parent.type === 'RegularElement' || parent.type === 'SvelteElement') {
if (parent.metadata.svg) {
return 'svg';
}
return parent.metadata.mathml ? 'mathml' : 'html';
}
// Re-evaluate the namespace inside slot nodes that reset the namespace
if (
parent.type === 'Fragment' ||
parent.type === 'Root' ||
parent.type === 'Component' ||
parent.type === 'SvelteComponent' ||
parent.type === 'SvelteFragment' ||
parent.type === 'SnippetBlock' ||
parent.type === 'SlotElement'
) {
const new_namespace = check_nodes_for_namespace(nodes, 'keep');
if (new_namespace !== 'keep' && new_namespace !== 'maybe_html') {
return new_namespace;
}
}
/** @type {Namespace | null} */
let new_namespace = null;
// Check the elements within the fragment and look for consistent namespaces.
// If we have no namespaces or they are mixed, then fallback to existing namespace
for (const node of nodes) {
if (node.type !== 'RegularElement') continue;
if (node.metadata.mathml) {
new_namespace = new_namespace === null || new_namespace === 'mathml' ? 'mathml' : 'html';
} else if (node.metadata.svg) {
new_namespace = new_namespace === null || new_namespace === 'svg' ? 'svg' : 'html';
} else {
return 'html';
}
}
return new_namespace ?? namespace;
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does infer_namespace() do?
infer_namespace() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/3-transform/utils.js.
Where is infer_namespace() defined?
infer_namespace() is defined in packages/svelte/src/compiler/phases/3-transform/utils.js at line 313.
What does infer_namespace() call?
infer_namespace() calls 1 function(s): check_nodes_for_namespace.
What calls infer_namespace()?
infer_namespace() is called by 2 function(s): Fragment, Fragment.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free