All files / src/compiler/phases/2-analyze/visitors SvelteFragment.js

93.1% Statements 27/29
90.9% Branches 10/11
100% Functions 1/1
92.59% Lines 25/27

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 282x 2x 2x 2x 2x 2x 2x 2x 2x 2x 73x 73x 2x 2x 71x 71x 116x 63x 63x 63x 116x     116x 69x 69x 69x  
/** @import { AST } from '#compiler' */
/** @import { Context } from '../types' */
import * as e from '../../../errors.js';
import { validate_slot_attribute } from './shared/attribute.js';
 
/**
 * @param {AST.SvelteFragment} node
 * @param {Context} context
 */
export function SvelteFragment(node, context) {
	const parent = context.path.at(-2);
	if (parent?.type !== 'Component' && parent?.type !== 'SvelteComponent') {
		e.svelte_fragment_invalid_placement(node);
	}
 
	for (const attribute of node.attributes) {
		if (attribute.type === 'Attribute') {
			if (attribute.name === 'slot') {
				validate_slot_attribute(context, attribute);
			}
		} else if (attribute.type !== 'LetDirective') {
			e.svelte_fragment_invalid_attribute(attribute);
		}
	}
 
	context.next({ ...context.state, parent_element: null });
}