Home / Function/ fragment_from_tree() — svelte Function Reference

fragment_from_tree() — svelte Function Reference

Architecture documentation for the fragment_from_tree() function in template.js from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  9377bbc7_f1f5_56f6_87e1_cfa79859a6b7["fragment_from_tree()"]
  2ab7c579_f011_f472_7847_c9e9979c6b2a["template.js"]
  9377bbc7_f1f5_56f6_87e1_cfa79859a6b7 -->|defined in| 2ab7c579_f011_f472_7847_c9e9979c6b2a
  7232e4f4_c61f_9ad7_a651_1b6fdca3a287["from_tree()"]
  7232e4f4_c61f_9ad7_a651_1b6fdca3a287 -->|calls| 9377bbc7_f1f5_56f6_87e1_cfa79859a6b7
  37e01e79_1cb8_e9dd_773c_5301bb72975c["create_fragment()"]
  9377bbc7_f1f5_56f6_87e1_cfa79859a6b7 -->|calls| 37e01e79_1cb8_e9dd_773c_5301bb72975c
  e3f9d623_9f97_2d01_0473_63e757414179["append()"]
  9377bbc7_f1f5_56f6_87e1_cfa79859a6b7 -->|calls| e3f9d623_9f97_2d01_0473_63e757414179
  ec54e18a_a454_5d8c_9e00_7bc16e4f49c4["create_text()"]
  9377bbc7_f1f5_56f6_87e1_cfa79859a6b7 -->|calls| ec54e18a_a454_5d8c_9e00_7bc16e4f49c4
  ad2d3e5b_92c4_44cd_6972_84b884432025["create_comment()"]
  9377bbc7_f1f5_56f6_87e1_cfa79859a6b7 -->|calls| ad2d3e5b_92c4_44cd_6972_84b884432025
  e4e52826_98b2_5b51_9187_77e2fcc4adbb["create_element()"]
  9377bbc7_f1f5_56f6_87e1_cfa79859a6b7 -->|calls| e4e52826_98b2_5b51_9187_77e2fcc4adbb
  f4910c1d_4706_d871_1b71_4336dcb2d00c["set_attribute()"]
  9377bbc7_f1f5_56f6_87e1_cfa79859a6b7 -->|calls| f4910c1d_4706_d871_1b71_4336dcb2d00c
  style 9377bbc7_f1f5_56f6_87e1_cfa79859a6b7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/internal/client/dom/template.js lines 162–202

function fragment_from_tree(structure, ns) {
	var fragment = create_fragment();

	for (var item of structure) {
		if (typeof item === 'string') {
			fragment.append(create_text(item));
			continue;
		}

		// if `preserveComments === true`, comments are represented as `['// <data>']`
		if (item === undefined || item[0][0] === '/') {
			fragment.append(create_comment(item ? item[0].slice(3) : ''));
			continue;
		}

		const [name, attributes, ...children] = item;

		const namespace = name === 'svg' ? NAMESPACE_SVG : name === 'math' ? NAMESPACE_MATHML : ns;

		var element = create_element(name, namespace, attributes?.is);

		for (var key in attributes) {
			set_attribute(element, key, attributes[key]);
		}

		if (children.length > 0) {
			var target =
				element.tagName === 'TEMPLATE'
					? /** @type {HTMLTemplateElement} */ (element).content
					: element;

			target.append(
				fragment_from_tree(children, element.tagName === 'foreignObject' ? undefined : namespace)
			);
		}

		fragment.append(element);
	}

	return fragment;
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does fragment_from_tree() do?
fragment_from_tree() is a function in the svelte codebase, defined in packages/svelte/src/internal/client/dom/template.js.
Where is fragment_from_tree() defined?
fragment_from_tree() is defined in packages/svelte/src/internal/client/dom/template.js at line 162.
What does fragment_from_tree() call?
fragment_from_tree() calls 6 function(s): append, create_comment, create_element, create_fragment, create_text, set_attribute.
What calls fragment_from_tree()?
fragment_from_tree() is called by 1 function(s): from_tree.

Analyze Your Own Codebase

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

Try Supermodel Free