Home / Function/ template.SvelteSelf() — svelte Function Reference

template.SvelteSelf() — svelte Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  bbe5eaba_74a6_6c69_bf91_6f8c677d93cd["template.SvelteSelf()"]
  cab41022_1b55_3b7a_06c6_b90763bbea47["index.js"]
  bbe5eaba_74a6_6c69_bf91_6f8c677d93cd -->|defined in| cab41022_1b55_3b7a_06c6_b90763bbea47
  11646a18_8daa_784f_c157_e7c537873a8e["guess_indent()"]
  bbe5eaba_74a6_6c69_bf91_6f8c677d93cd -->|calls| 11646a18_8daa_784f_c157_e7c537873a8e
  style bbe5eaba_74a6_6c69_bf91_6f8c677d93cd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/svelte/src/compiler/migrate/index.js lines 1076–1112

	SvelteSelf(node, { state, next }) {
		const source = state.str.original.substring(node.start, node.end);
		if (!state.filename) {
			const indent = guess_indent(source);
			has_migration_task = true;
			state.str.prependRight(
				node.start,
				`<!-- @migration-task: svelte:self is deprecated, import this Svelte file into itself instead -->\n${indent}`
			);
			next();
			return;
		}
		// overwrite the open tag
		state.str.overwrite(
			node.start + 1,
			node.start + 1 + 'svelte:self'.length,
			`${state.analysis.name}`
		);
		// if it has a fragment we need to overwrite the closing tag too
		if (node.fragment.nodes.length > 0) {
			state.str.overwrite(
				state.str.original.lastIndexOf('<', node.end) + 2,
				node.end - 1,
				`${state.analysis.name}`
			);
		} else if (!source.endsWith('/>')) {
			// special case for case `<svelte:self></svelte:self>` it has no fragment but
			// we still need to overwrite the end tag
			state.str.overwrite(
				node.start + source.lastIndexOf('</', node.end) + 2,
				node.end - 1,
				`${state.analysis.name}`
			);
		}
		state.has_svelte_self = true;
		next();
	},

Domain

Subdomains

Frequently Asked Questions

What does template.SvelteSelf() do?
template.SvelteSelf() is a function in the svelte codebase, defined in packages/svelte/src/compiler/migrate/index.js.
Where is template.SvelteSelf() defined?
template.SvelteSelf() is defined in packages/svelte/src/compiler/migrate/index.js at line 1076.
What does template.SvelteSelf() call?
template.SvelteSelf() calls 1 function(s): guess_indent.

Analyze Your Own Codebase

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

Try Supermodel Free