Home / Function/ push_element() — svelte Function Reference

push_element() — svelte Function Reference

Architecture documentation for the push_element() function in dev.js from the svelte codebase.

Entity Profile

Dependency Diagram

graph TD
  5e189954_74f0_0aa0_89f7_83b3ae199b34["push_element()"]
  4440efa2_b84c_d186_53ca_534b0add2937["dev.js"]
  5e189954_74f0_0aa0_89f7_83b3ae199b34 -->|defined in| 4440efa2_b84c_d186_53ca_534b0add2937
  b52e7925_73b5_1187_beab_fb7eb59cc45d["is_tag_valid_with_parent()"]
  5e189954_74f0_0aa0_89f7_83b3ae199b34 -->|calls| b52e7925_73b5_1187_beab_fb7eb59cc45d
  8f461753_4477_447d_7660_06be26639f8c["print_error()"]
  5e189954_74f0_0aa0_89f7_83b3ae199b34 -->|calls| 8f461753_4477_447d_7660_06be26639f8c
  f7866d2b_dae9_12da_76a2_8cd373b8b5db["is_tag_valid_with_ancestor()"]
  5e189954_74f0_0aa0_89f7_83b3ae199b34 -->|calls| f7866d2b_dae9_12da_76a2_8cd373b8b5db
  fd36db6e_7997_3606_5582_56b6e78ced09["set_ssr_context()"]
  5e189954_74f0_0aa0_89f7_83b3ae199b34 -->|calls| fd36db6e_7997_3606_5582_56b6e78ced09
  6f1eae94_35bd_e5bc_d962_31f3ce608951["push()"]
  5e189954_74f0_0aa0_89f7_83b3ae199b34 -->|calls| 6f1eae94_35bd_e5bc_d962_31f3ce608951
  style 5e189954_74f0_0aa0_89f7_83b3ae199b34 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/internal/server/dev.js lines 57–89

export function push_element(renderer, tag, line, column) {
	var context = /** @type {SSRContext} */ (ssr_context);
	var filename = context.function[FILENAME];
	var parent = context.element;
	var element = { tag, parent, filename, line, column };

	if (parent !== undefined) {
		var ancestor = parent.parent;
		var ancestors = [parent.tag];

		const child_loc = filename ? `${filename}:${line}:${column}` : undefined;
		const parent_loc = parent.filename
			? `${parent.filename}:${parent.line}:${parent.column}`
			: undefined;

		const message = is_tag_valid_with_parent(tag, parent.tag, child_loc, parent_loc);
		if (message) print_error(renderer, message);

		while (ancestor != null) {
			ancestors.push(ancestor.tag);
			const ancestor_loc = ancestor.filename
				? `${ancestor.filename}:${ancestor.line}:${ancestor.column}`
				: undefined;

			const message = is_tag_valid_with_ancestor(tag, ancestors, child_loc, ancestor_loc);
			if (message) print_error(renderer, message);

			ancestor = ancestor.parent;
		}
	}

	set_ssr_context({ ...context, p: context, element });
}

Domain

Subdomains

Frequently Asked Questions

What does push_element() do?
push_element() is a function in the svelte codebase, defined in packages/svelte/src/internal/server/dev.js.
Where is push_element() defined?
push_element() is defined in packages/svelte/src/internal/server/dev.js at line 57.
What does push_element() call?
push_element() calls 5 function(s): is_tag_valid_with_ancestor, is_tag_valid_with_parent, print_error, push, set_ssr_context.

Analyze Your Own Codebase

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

Try Supermodel Free