Home / File/ HtmlTag.js — svelte Source File

HtmlTag.js — svelte Source File

Architecture documentation for HtmlTag.js, a javascript file in the svelte codebase. 5 imports, 1 dependents.

File javascript Compiler Transformer 5 imports 1 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  3e79f9e1_7f70_480a_576e_b70c54bd2638["HtmlTag.js"]
  62f818c8_e890_17ed_5ec1_92f953d4a7a6["state.js"]
  3e79f9e1_7f70_480a_576e_b70c54bd2638 --> 62f818c8_e890_17ed_5ec1_92f953d4a7a6
  7a7783f8_ffa6_0cc3_61b0_031882649535["is_ignored"]
  3e79f9e1_7f70_480a_576e_b70c54bd2638 --> 7a7783f8_ffa6_0cc3_61b0_031882649535
  d04d7971_88df_542d_dd4f_26170ce6f581["utils.js"]
  3e79f9e1_7f70_480a_576e_b70c54bd2638 --> d04d7971_88df_542d_dd4f_26170ce6f581
  66243dec_e2be_a66d_3992_3ea42cf964b5["build_expression"]
  3e79f9e1_7f70_480a_576e_b70c54bd2638 --> 66243dec_e2be_a66d_3992_3ea42cf964b5
  95c28355_f14c_c3cd_5a03_d5a53ca255bc["builders"]
  3e79f9e1_7f70_480a_576e_b70c54bd2638 --> 95c28355_f14c_c3cd_5a03_d5a53ca255bc
  7665e008_f37d_b860_a594_f2539a66af4e["transform-client.js"]
  7665e008_f37d_b860_a594_f2539a66af4e --> 3e79f9e1_7f70_480a_576e_b70c54bd2638
  style 3e79f9e1_7f70_480a_576e_b70c54bd2638 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/** @import { AST } from '#compiler' */
/** @import { ComponentContext } from '../types' */
import { is_ignored } from '../../../../state.js';
import * as b from '#compiler/builders';
import { build_expression } from './shared/utils.js';

/**
 * @param {AST.HtmlTag} node
 * @param {ComponentContext} context
 */
export function HtmlTag(node, context) {
	context.state.template.push_comment();

	const has_await = node.metadata.expression.has_await;
	const has_blockers = node.metadata.expression.has_blockers();

	const expression = build_expression(context, node.expression, node.metadata.expression);
	const html = has_await ? b.call('$.get', b.id('$$html')) : expression;

	const is_svg = context.state.metadata.namespace === 'svg';
	const is_mathml = context.state.metadata.namespace === 'mathml';

	const statement = b.stmt(
		b.call(
			'$.html',
			context.state.node,
			b.thunk(html),
			is_svg && b.true,
			is_mathml && b.true,
			is_ignored(node, 'hydration_html_changed') && b.true
		)
	);

	// push into init, so that bindings run afterwards, which might trigger another run and override hydration
	if (has_await || has_blockers) {
		context.state.init.push(
			b.stmt(
				b.call(
					'$.async',
					context.state.node,
					node.metadata.expression.blockers(),
					has_await ? b.array([b.thunk(expression, true)]) : b.void0,
					b.arrow(
						has_await ? [context.state.node, b.id('$$html')] : [context.state.node],
						b.block([statement])
					)
				)
			)
		);
	} else {
		context.state.init.push(statement);
	}
}

Domain

Subdomains

Functions

Frequently Asked Questions

What does HtmlTag.js do?
HtmlTag.js is a source file in the svelte codebase, written in javascript. It belongs to the Compiler domain, Transformer subdomain.
What functions are defined in HtmlTag.js?
HtmlTag.js defines 1 function(s): HtmlTag.
What does HtmlTag.js depend on?
HtmlTag.js imports 5 module(s): build_expression, builders, is_ignored, state.js, utils.js.
What files import HtmlTag.js?
HtmlTag.js is imported by 1 file(s): transform-client.js.
Where is HtmlTag.js in the architecture?
HtmlTag.js is located at packages/svelte/src/compiler/phases/3-transform/client/visitors/HtmlTag.js (domain: Compiler, subdomain: Transformer, directory: packages/svelte/src/compiler/phases/3-transform/client/visitors).

Analyze Your Own Codebase

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

Try Supermodel Free