All files / src/compiler/utils slot.js

100% Statements 22/22
100% Branches 16/16
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 8219x 4859x 8217x 4488x 4462x 4274x 510x 510x 510x 4349x 4349x 4349x  
/** @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;
}