Home / Function/ loop_child() — svelte Function Reference

loop_child() — svelte Function Reference

Architecture documentation for the loop_child() function in css-prune.js from the svelte codebase.

Function javascript Compiler Analyzer calls 4 called by 1

Entity Profile

Dependency Diagram

graph TD
  f1ba25ad_bb71_e826_ea99_c51b13d5cd8b["loop_child()"]
  cb1bf043_dade_7352_cc2b_976ffa2968d8["css-prune.js"]
  f1ba25ad_bb71_e826_ea99_c51b13d5cd8b -->|defined in| cb1bf043_dade_7352_cc2b_976ffa2968d8
  14568a03_9aaf_6654_12a2_6715c1feb40f["get_possible_nested_siblings()"]
  14568a03_9aaf_6654_12a2_6715c1feb40f -->|calls| f1ba25ad_bb71_e826_ea99_c51b13d5cd8b
  69fc97cc_09aa_8b84_a7ce_425c1db8c339["add_to_map()"]
  f1ba25ad_bb71_e826_ea99_c51b13d5cd8b -->|calls| 69fc97cc_09aa_8b84_a7ce_425c1db8c339
  14568a03_9aaf_6654_12a2_6715c1feb40f["get_possible_nested_siblings()"]
  f1ba25ad_bb71_e826_ea99_c51b13d5cd8b -->|calls| 14568a03_9aaf_6654_12a2_6715c1feb40f
  5850e1d2_00c3_46f8_65a8_3e14a5008835["is_block()"]
  f1ba25ad_bb71_e826_ea99_c51b13d5cd8b -->|calls| 5850e1d2_00c3_46f8_65a8_3e14a5008835
  72641a2e_b8fc_984b_8f67_3250d77a3ede["has_definite_elements()"]
  f1ba25ad_bb71_e826_ea99_c51b13d5cd8b -->|calls| 72641a2e_b8fc_984b_8f67_3250d77a3ede
  style f1ba25ad_bb71_e826_ea99_c51b13d5cd8b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/phases/2-analyze/css/css-prune.js lines 1114–1146

function loop_child(children, direction, adjacent_only, seen) {
	/** @type {Map<Compiler.AST.RegularElement | Compiler.AST.SvelteElement, NodeExistsValue>} */
	const result = new Map();

	let i = direction === FORWARD ? 0 : children.length - 1;

	while (i >= 0 && i < children.length) {
		const child = children[i];

		if (child.type === 'RegularElement') {
			result.set(child, NODE_DEFINITELY_EXISTS);
			if (adjacent_only) {
				break;
			}
		} else if (child.type === 'SvelteElement') {
			result.set(child, NODE_PROBABLY_EXISTS);
		} else if (child.type === 'RenderTag') {
			for (const snippet of child.metadata.snippets) {
				add_to_map(get_possible_nested_siblings(snippet, direction, adjacent_only, seen), result);
			}
		} else if (is_block(child)) {
			const child_result = get_possible_nested_siblings(child, direction, adjacent_only, seen);
			add_to_map(child_result, result);
			if (adjacent_only && has_definite_elements(child_result)) {
				break;
			}
		}

		i = direction === FORWARD ? i + 1 : i - 1;
	}

	return result;
}

Domain

Subdomains

Frequently Asked Questions

What does loop_child() do?
loop_child() is a function in the svelte codebase, defined in packages/svelte/src/compiler/phases/2-analyze/css/css-prune.js.
Where is loop_child() defined?
loop_child() is defined in packages/svelte/src/compiler/phases/2-analyze/css/css-prune.js at line 1114.
What does loop_child() call?
loop_child() calls 4 function(s): add_to_map, get_possible_nested_siblings, has_definite_elements, is_block.
What calls loop_child()?
loop_child() is called by 1 function(s): get_possible_nested_siblings.

Analyze Your Own Codebase

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

Try Supermodel Free