MCPcopy
hub / github.com/sveltejs/svelte / BranchManager

Class BranchManager

packages/svelte/src/internal/client/dom/blocks/branches.js:22–238  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20 * @template Key
21 */
22export class BranchManager {
23 /** @type {TemplateNode} */
24 anchor;
25
26 /** @type {Map<Batch, Key>} */
27 #batches = new Map();
28
29 /**
30 * Map of keys to effects that are currently rendered in the DOM.
31 * These effects are visible and actively part of the document tree.
32 * Example:
33 * ```
34 * {#if condition}
35 * foo
36 * {:else}
37 * bar
38 * {/if}
39 * ```
40 * Can result in the entries `true->Effect` and `false->Effect`
41 * @type {Map<Key, Effect>}
42 */
43 #onscreen = new Map();
44
45 /**
46 * Similar to #onscreen with respect to the keys, but contains branches that are not yet
47 * in the DOM, because their insertion is deferred.
48 * @type {Map<Key, Branch>}
49 */
50 #offscreen = new Map();
51
52 /**
53 * Keys of effects that are currently outroing
54 * @type {Set<Key>}
55 */
56 #outroing = new Set();
57
58 /**
59 * Whether to pause (i.e. outro) on change, or destroy immediately.
60 * This is necessary for `<svelte:element>`
61 */
62 #transition = true;
63
64 /**
65 * @param {TemplateNode} anchor
66 * @param {boolean} transition
67 */
68 constructor(anchor, transition = true) {
69 this.anchor = anchor;
70 this.#transition = transition;
71 }
72
73 /**
74 * @param {Batch} batch
75 */
76 #commit = (batch) => {
77 // if this batch was made obsolete, bail
78 if (!this.#batches.has(batch)) return;
79

Callers

nothing calls this directly

Calls 9

resume_effectFunction · 0.90
destroy_effectFunction · 0.90
pause_effectFunction · 0.90
setMethod · 0.65
hasMethod · 0.45
getMethod · 0.45
deleteMethod · 0.45
addMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected