Home / File/ attachments.js — svelte Source File

attachments.js — svelte Source File

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

File javascript ClientRuntime Hydration 5 imports 2 dependents 1 functions

Entity Profile

Dependency Diagram

graph LR
  da569db2_9d2a_e7c6_6b96_4551a150836c["attachments.js"]
  1ae6fa4e_16ee_acdf_5e28_17eb0819fddb["effects.js"]
  da569db2_9d2a_e7c6_6b96_4551a150836c --> 1ae6fa4e_16ee_acdf_5e28_17eb0819fddb
  4ca1b5f2_087e_afec_72d9_534a30fbfe1f["branch"]
  da569db2_9d2a_e7c6_6b96_4551a150836c --> 4ca1b5f2_087e_afec_72d9_534a30fbfe1f
  a985ae40_8ef8_7ef2_adad_116fbf97e70c["effect"]
  da569db2_9d2a_e7c6_6b96_4551a150836c --> a985ae40_8ef8_7ef2_adad_116fbf97e70c
  410f774f_2d1a_7114_fcba_b292ed7cae3a["destroy_effect"]
  da569db2_9d2a_e7c6_6b96_4551a150836c --> 410f774f_2d1a_7114_fcba_b292ed7cae3a
  a3686fa4_d487_d514_9dcd_bcbf5853b659["managed"]
  da569db2_9d2a_e7c6_6b96_4551a150836c --> a3686fa4_d487_d514_9dcd_bcbf5853b659
  0acd2537_e1bf_d7ae_30d5_407378cfa4d3["attributes.js"]
  0acd2537_e1bf_d7ae_30d5_407378cfa4d3 --> da569db2_9d2a_e7c6_6b96_4551a150836c
  4871424a_ea24_562e_42c1_423f3652e63b["customizable-select.js"]
  4871424a_ea24_562e_42c1_423f3652e63b --> da569db2_9d2a_e7c6_6b96_4551a150836c
  style da569db2_9d2a_e7c6_6b96_4551a150836c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

/** @import { Effect } from '#client' */
import { branch, effect, destroy_effect, managed } from '../../reactivity/effects.js';

// TODO in 6.0 or 7.0, when we remove legacy mode, we can simplify this by
// getting rid of the block/branch stuff and just letting the effect rip.
// see https://github.com/sveltejs/svelte/pull/15962

/**
 * @param {Element} node
 * @param {() => (node: Element) => void} get_fn
 */
export function attach(node, get_fn) {
	/** @type {false | undefined | ((node: Element) => void)} */
	var fn = undefined;

	/** @type {Effect | null} */
	var e;

	managed(() => {
		if (fn !== (fn = get_fn())) {
			if (e) {
				destroy_effect(e);
				e = null;
			}

			if (fn) {
				e = branch(() => {
					effect(() => /** @type {(node: Element) => void} */ (fn)(node));
				});
			}
		}
	});
}

Domain

Subdomains

Functions

Frequently Asked Questions

What does attachments.js do?
attachments.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 attachments.js?
attachments.js defines 1 function(s): attach.
What does attachments.js depend on?
attachments.js imports 5 module(s): branch, destroy_effect, effect, effects.js, managed.
What files import attachments.js?
attachments.js is imported by 2 file(s): attributes.js, customizable-select.js.
Where is attachments.js in the architecture?
attachments.js is located at packages/svelte/src/internal/client/dom/elements/attachments.js (domain: ClientRuntime, subdomain: Hydration, directory: packages/svelte/src/internal/client/dom/elements).

Analyze Your Own Codebase

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

Try Supermodel Free