All files / src/compiler/utils slot.js

100% Statements 22/22
100% Branches 15/15
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 8230x 4870x 8230x 4499x 4473x 4281x 510x 510x 510x 4360x 4360x 4360x  
/** @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;
}