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 8692x 5138x 8692x 4653x 4627x 4435x 552x 552x 552x 4586x 4586x 4586x  
/** @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;
}