All files / src/internal/client/dom/blocks slot.js

100% Statements 22/22
100% Branches 5/5
100% Functions 1/1
100% Lines 21/21

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 222x 2x 2x 2x 2x 2x 2x 2x 2x 651x 292x 292x 651x 651x 42x 32x 32x 651x 609x 609x 651x  
import { hydrate_next, hydrating } from '../hydration.js';
 
/**
 * @param {Comment} anchor
 * @param {void | ((anchor: Comment, slot_props: Record<string, unknown>) => void)} slot_fn
 * @param {Record<string, unknown>} slot_props
 * @param {null | ((anchor: Comment) => void)} fallback_fn
 */
export function slot(anchor, slot_fn, slot_props, fallback_fn) {
	if (hydrating) {
		hydrate_next();
	}
 
	if (slot_fn === undefined) {
		if (fallback_fn !== null) {
			fallback_fn(anchor);
		}
	} else {
		slot_fn(anchor, slot_props);
	}
}