svelte
Advanced tools
Comparing version 5.0.0-next.88 to 5.0.0-next.89
@@ -5,3 +5,3 @@ { | ||
"license": "MIT", | ||
"version": "5.0.0-next.88", | ||
"version": "5.0.0-next.89", | ||
"type": "module", | ||
@@ -48,2 +48,5 @@ "types": "./types/index.d.ts", | ||
}, | ||
"./internal": { | ||
"default": "./src/internal/index.js" | ||
}, | ||
"./internal/client": { | ||
@@ -50,0 +53,0 @@ "default": "./src/internal/client/index.js" |
@@ -6,3 +6,2 @@ import { DEV } from 'esm-env'; | ||
current_effect, | ||
destroy_children, | ||
remove_reactions, | ||
@@ -15,2 +14,3 @@ set_signal_status, | ||
import { equals, safe_equals } from './equality.js'; | ||
import { destroy_effect } from './effects.js'; | ||
@@ -47,6 +47,7 @@ export let updating_derived = false; | ||
if (current_reaction !== null && (current_reaction.f & DERIVED) !== 0) { | ||
if (current_reaction.deriveds === null) { | ||
current_reaction.deriveds = [signal]; | ||
var current_derived = /** @type {import('#client').Derived<V>} */ (current_reaction); | ||
if (current_derived.deriveds === null) { | ||
current_derived.deriveds = [signal]; | ||
} else { | ||
current_reaction.deriveds.push(signal); | ||
current_derived.deriveds.push(signal); | ||
} | ||
@@ -71,2 +72,26 @@ } | ||
/** | ||
* @param {import('./types.js').Derived} signal | ||
* @returns {void} | ||
*/ | ||
function destroy_derived_children(signal) { | ||
var effects = signal.effects; | ||
// TODO: should it be possible to create effects in deriveds given they're meant to be pure? | ||
if (effects !== null) { | ||
signal.effects = null; | ||
for (var i = 0; i < effects.length; i += 1) { | ||
destroy_effect(effects[i]); | ||
} | ||
} | ||
var deriveds = signal.deriveds; | ||
if (deriveds !== null) { | ||
signal.deriveds = null; | ||
for (i = 0; i < deriveds.length; i += 1) { | ||
destroy_derived(deriveds[i]); | ||
} | ||
} | ||
} | ||
/** | ||
* @param {import('#client').Derived} derived | ||
@@ -79,3 +104,3 @@ * @param {boolean} force_schedule | ||
updating_derived = true; | ||
destroy_children(derived); | ||
destroy_derived_children(derived); | ||
var value = execute_reaction_fn(derived); | ||
@@ -106,3 +131,3 @@ updating_derived = previous_updating_derived; | ||
export function destroy_derived(signal) { | ||
destroy_children(signal); | ||
destroy_derived_children(signal); | ||
remove_reactions(signal, 0); | ||
@@ -109,0 +134,0 @@ set_signal_status(signal, DESTROYED); |
@@ -49,3 +49,2 @@ import { DEV } from 'esm-env'; | ||
effects: null, | ||
deriveds: null, | ||
teardown: null, | ||
@@ -242,2 +241,12 @@ ctx: current_component_context, | ||
var parent = effect.parent; | ||
if (parent !== null && (effect.f & BRANCH_EFFECT) !== 0) { | ||
var effects = parent.effects; | ||
if (effects !== null) { | ||
var index = effects.indexOf(effect); | ||
effects.splice(index, 1); | ||
} | ||
} | ||
effect.effects = | ||
@@ -248,2 +257,3 @@ effect.teardown = | ||
effect.deps = | ||
effect.parent = | ||
// @ts-expect-error | ||
@@ -250,0 +260,0 @@ effect.fn = |
@@ -26,4 +26,2 @@ import type { ComponentContext, Dom, Equals, TransitionManager } from '#client'; | ||
effects: null | Effect[]; | ||
/** Deriveds created inside this signal */ | ||
deriveds: null | Derived[]; | ||
} | ||
@@ -34,2 +32,4 @@ | ||
fn: () => V; | ||
/** Deriveds created inside this signal */ | ||
deriveds: null | Derived[]; | ||
} | ||
@@ -36,0 +36,0 @@ |
@@ -352,18 +352,13 @@ import { DEV } from 'esm-env'; | ||
/** | ||
* @param {import('./types.js').Reaction} signal | ||
* @param {import('./types.js').Effect} signal | ||
* @returns {void} | ||
*/ | ||
export function destroy_children(signal) { | ||
if (signal.effects) { | ||
for (var i = 0; i < signal.effects.length; i += 1) { | ||
destroy_effect(signal.effects[i]); | ||
} | ||
var effects = signal.effects; | ||
if (effects !== null) { | ||
signal.effects = null; | ||
} | ||
if (signal.deriveds) { | ||
for (i = 0; i < signal.deriveds.length; i += 1) { | ||
destroy_derived(signal.deriveds[i]); | ||
for (var i = 0; i < effects.length; i += 1) { | ||
destroy_effect(effects[i]); | ||
} | ||
signal.deriveds = null; | ||
} | ||
@@ -370,0 +365,0 @@ } |
@@ -164,7 +164,7 @@ import { is_promise, noop } from '../shared/utils.js'; | ||
if (tag !== 'textarea') { | ||
payload.out += '<![>'; | ||
payload.out += '<!--[-->'; | ||
} | ||
children_fn(); | ||
if (tag !== 'textarea') { | ||
payload.out += '<!]>'; | ||
payload.out += '<!--]-->'; | ||
} | ||
@@ -191,3 +191,3 @@ payload.out += `</${tag}>`; | ||
on_destroy = []; | ||
payload.out += '<![>'; | ||
payload.out += '<!--[-->'; | ||
@@ -205,3 +205,3 @@ if (options.context) { | ||
payload.out += '<!]>'; | ||
payload.out += '<!--]-->'; | ||
for (const cleanup of on_destroy) cleanup(); | ||
@@ -213,3 +213,3 @@ on_destroy = prev_on_destroy; | ||
payload.head.out || payload.head.title | ||
? payload.head.title + '<![>' + payload.head.out + '<!]>' | ||
? payload.head.title + '<!--[-->' + payload.head.out + '<!--]-->' | ||
: '', | ||
@@ -278,11 +278,11 @@ html: payload.out | ||
if (is_html) { | ||
payload.out += `<div style="display: contents; ${styles}"><![>`; | ||
payload.out += `<div style="display: contents; ${styles}"><!--[-->`; | ||
} else { | ||
payload.out += `<g style="${styles}"><![>`; | ||
payload.out += `<g style="${styles}"><!--[-->`; | ||
} | ||
component(); | ||
if (is_html) { | ||
payload.out += `<!]></div>`; | ||
payload.out += `<!--]--></div>`; | ||
} else { | ||
payload.out += `<!]></g>`; | ||
payload.out += `<!--]--></g>`; | ||
} | ||
@@ -289,0 +289,0 @@ } |
@@ -9,3 +9,3 @@ // generated during release, do not modify | ||
*/ | ||
export const VERSION = '5.0.0-next.88'; | ||
export const VERSION = '5.0.0-next.89'; | ||
export const PUBLIC_VERSION = '5'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1907414
188
40856
59
166
26
4