All files / src/compiler/phases/3-transform/server/visitors RenderTag.js

100% Statements 38/38
100% Branches 5/5
100% Functions 1/1
100% Lines 35/35

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 362x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 75x 75x 75x 75x 75x 75x 29x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 75x 61x 61x 75x  
/** @import { Expression } from 'estree' */
/** @import { RenderTag } from '#compiler' */
/** @import { ComponentContext } from '../types.js' */
import { unwrap_optional } from '../../../../utils/ast.js';
import * as b from '../../../../utils/builders.js';
import { empty_comment } from './shared/utils.js';
 
/**
 * @param {RenderTag} node
 * @param {ComponentContext} context
 */
export function RenderTag(node, context) {
	const callee = unwrap_optional(node.expression).callee;
	const raw_args = unwrap_optional(node.expression).arguments;
 
	const snippet_function = /** @type {Expression} */ (context.visit(callee));
 
	const snippet_args = raw_args.map((arg) => {
		return /** @type {Expression} */ (context.visit(arg));
	});
 
	context.state.template.push(
		b.stmt(
			(node.expression.type === 'CallExpression' ? b.call : b.maybe_call)(
				snippet_function,
				b.id('$$payload'),
				...snippet_args
			)
		)
	);
 
	if (!context.state.skip_hydration_boundaries) {
		context.state.template.push(empty_comment);
	}
}