All files / src/compiler/utils slot.js

100% Statements 22/22
100% Branches 14/14
100% Functions 1/1
100% Lines 20/20

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 212x 2x 2x 2x 2x 2x 2x 2x 8866x 5233x 8866x 4713x 4687x 4495x 582x 582x 582x 4651x 4651x 4651x  
/** @import { SvelteNode } from '#compiler' */
import { is_element_node } from '../phases/nodes.js';
import { is_text_attribute } from './ast.js';
 
/**
 * @param {SvelteNode} node
 */
export function determine_slot(node) {
	if (!is_element_node(node)) return null;
 
	for (const attribute of node.attributes) {
		if (attribute.type !== 'Attribute') continue;
		if (attribute.name !== 'slot') continue;
		if (!is_text_attribute(attribute)) continue;
 
		return /** @type {string} */ (attribute.value[0].data);
	}
 
	return null;
}