Home / Function/ check_nodes_for_namespace() — svelte Function Reference

check_nodes_for_namespace() — svelte Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  06f8b738_4399_59d6_de49_05b18c457206["check_nodes_for_namespace()"]
  f3fad5a9_6b91_ed4f_9331_7f9fc18491c3["utils.js"]
  06f8b738_4399_59d6_de49_05b18c457206 -->|defined in| f3fad5a9_6b91_ed4f_9331_7f9fc18491c3
  19ba44b1_ed7b_aeee_985f_f1c151bf7e44["infer_namespace()"]
  19ba44b1_ed7b_aeee_985f_f1c151bf7e44 -->|calls| 06f8b738_4399_59d6_de49_05b18c457206
  style 06f8b738_4399_59d6_de49_05b18c457206 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/phases/3-transform/utils.js lines 368–415

function check_nodes_for_namespace(nodes, namespace) {
	/**
	 * @param {AST.SvelteElement | AST.RegularElement} node}
	 * @param {{stop: () => void}} context
	 */
	const RegularElement = (node, { stop }) => {
		if (!node.metadata.svg && !node.metadata.mathml) {
			namespace = 'html';
			stop();
		} else if (namespace === 'keep') {
			namespace = node.metadata.svg ? 'svg' : 'mathml';
		}
	};

	for (const node of nodes) {
		walk(
			node,
			{},
			{
				_(node, { next }) {
					if (
						node.type === 'EachBlock' ||
						node.type === 'IfBlock' ||
						node.type === 'AwaitBlock' ||
						node.type === 'Fragment' ||
						node.type === 'KeyBlock' ||
						node.type === 'RegularElement' ||
						node.type === 'SvelteElement' ||
						node.type === 'Text'
					) {
						next();
					}
				},
				SvelteElement: RegularElement,
				RegularElement,
				Text(node) {
					if (node.data.trim() !== '') {
						namespace = 'maybe_html';
					}
				}
			}
		);

		if (namespace === 'html') return namespace;
	}

	return namespace;
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does check_nodes_for_namespace() do?
check_nodes_for_namespace() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/3-transform/utils.js.
Where is check_nodes_for_namespace() defined?
check_nodes_for_namespace() is defined in packages/svelte/src/compiler/phases/3-transform/utils.js at line 368.
What calls check_nodes_for_namespace()?
check_nodes_for_namespace() is called by 1 function(s): infer_namespace.

Analyze Your Own Codebase

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

Try Supermodel Free