Home / Function/ normalize_children() — svelte Function Reference

normalize_children() — svelte Function Reference

Architecture documentation for the normalize_children() function in assert.js from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  b5d50997_2063_87fb_f6c6_de871718d37b["normalize_children()"]
  2a2d28a9_d1e5_6b47_9375_279552e7c7f8["assert.js"]
  b5d50997_2063_87fb_f6c6_de871718d37b -->|defined in| 2a2d28a9_d1e5_6b47_9375_279552e7c7f8
  e2c721f4_c907_b96e_684b_444f841adea2["normalize_html()"]
  e2c721f4_c907_b96e_684b_444f841adea2 -->|calls| b5d50997_2063_87fb_f6c6_de871718d37b
  style b5d50997_2063_87fb_f6c6_de871718d37b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/tests/runtime-browser/assert.js lines 89–115

function normalize_children(node) {
	// sort attributes
	const attributes = Array.from(node.attributes).sort(
		(/** @type {any} */ a, /** @type {any} */ b) => {
			return a.name < b.name ? -1 : 1;
		}
	);

	attributes.forEach((/** @type{any} */ attr) => {
		node.removeAttribute(attr.name);
	});

	attributes.forEach((/** @type{any} */ attr) => {
		node.setAttribute(attr.name, attr.value);
	});

	// normalize styles
	if (node.hasAttribute('style')) {
		node.style = node.style.cssText;
	}

	for (let child of [...node.childNodes]) {
		if (child.nodeType === ELEMENT_NODE) {
			normalize_children(child);
		}
	}
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does normalize_children() do?
normalize_children() is a function in the svelte codebase, defined in packages/svelte/tests/runtime-browser/assert.js.
Where is normalize_children() defined?
normalize_children() is defined in packages/svelte/tests/runtime-browser/assert.js at line 89.
What calls normalize_children()?
normalize_children() is called by 1 function(s): normalize_html.

Analyze Your Own Codebase

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

Try Supermodel Free