Home / File/ slot.js — svelte Source File

slot.js — svelte Source File

Architecture documentation for slot.js, a javascript file in the svelte codebase. 2 imports, 0 dependents.

File javascript ClientRuntime Hydration 2 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  2537b828_1113_c3e6_b7bf_1ee136abf18f["slot.js"]
  f3948b0d_b92a_0767_ba6c_832767f4e2bb["hydration.js"]
  2537b828_1113_c3e6_b7bf_1ee136abf18f --> f3948b0d_b92a_0767_ba6c_832767f4e2bb
  b31601aa_35ce_7827_5394_99fb97fa27d2["hydrate_next"]
  2537b828_1113_c3e6_b7bf_1ee136abf18f --> b31601aa_35ce_7827_5394_99fb97fa27d2
  style 2537b828_1113_c3e6_b7bf_1ee136abf18f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { hydrate_next, hydrating } from '../hydration.js';

/**
 * @param {Comment} anchor
 * @param {Record<string, any>} $$props
 * @param {string} name
 * @param {Record<string, unknown>} slot_props
 * @param {null | ((anchor: Comment) => void)} fallback_fn
 */
export function slot(anchor, $$props, name, slot_props, fallback_fn) {
	if (hydrating) {
		hydrate_next();
	}

	var slot_fn = $$props.$$slots?.[name];
	// Interop: Can use snippets to fill slots
	var is_interop = false;
	if (slot_fn === true) {
		slot_fn = $$props[name === 'default' ? 'children' : name];
		is_interop = true;
	}

	if (slot_fn === undefined) {
		if (fallback_fn !== null) {
			fallback_fn(anchor);
		}
	} else {
		slot_fn(anchor, is_interop ? () => slot_props : slot_props);
	}
}

/**
 * @param {Record<string, any>} props
 * @returns {Record<string, boolean>}
 */
export function sanitize_slots(props) {
	/** @type {Record<string, boolean>} */
	const sanitized = {};
	if (props.children) sanitized.default = true;
	for (const key in props.$$slots) {
		sanitized[key] = true;
	}
	return sanitized;
}

Domain

Subdomains

Frequently Asked Questions

What does slot.js do?
slot.js is a source file in the svelte codebase, written in javascript. It belongs to the ClientRuntime domain, Hydration subdomain.
What functions are defined in slot.js?
slot.js defines 2 function(s): sanitize_slots, slot.
What does slot.js depend on?
slot.js imports 2 module(s): hydrate_next, hydration.js.
Where is slot.js in the architecture?
slot.js is located at packages/svelte/src/internal/client/dom/blocks/slot.js (domain: ClientRuntime, subdomain: Hydration, directory: packages/svelte/src/internal/client/dom/blocks).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free