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 69x 69x 2x 2x 67x 67x 109x 60x 60x 60x 109x     109x 65x 65x 65x  
/** @import { SvelteFragment } from '#compiler' */
/** @import { Context } from '../types' */
import * as e from '../../../errors.js';
import { validate_slot_attribute } from './shared/attribute.js';
 
/**
 * @param {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 });
}