From 8a1acac084096d9c9bd15a1356d3251383e8d258 Mon Sep 17 00:00:00 2001 From: Paolo Ricciuti Date: Mon, 13 Jan 2025 22:17:39 +0100 Subject: [PATCH] fix: never consider inert boundary effects (#14999) * fix: never consider inert boundary effects * chore: inline bitwise --- .changeset/healthy-hairs-run.md | 5 +++++ .../src/internal/client/reactivity/effects.js | 5 +++-- .../samples/error-boundary-21/Child.svelte | 3 +++ .../samples/error-boundary-21/_config.js | 17 +++++++++++++++++ .../samples/error-boundary-21/main.svelte | 14 ++++++++++++++ 5 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 .changeset/healthy-hairs-run.md create mode 100644 packages/svelte/tests/runtime-runes/samples/error-boundary-21/Child.svelte create mode 100644 packages/svelte/tests/runtime-runes/samples/error-boundary-21/_config.js create mode 100644 packages/svelte/tests/runtime-runes/samples/error-boundary-21/main.svelte diff --git a/.changeset/healthy-hairs-run.md b/.changeset/healthy-hairs-run.md new file mode 100644 index 0000000000..5f0ccd5234 --- /dev/null +++ b/.changeset/healthy-hairs-run.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: never consider inert boundary effects diff --git a/packages/svelte/src/internal/client/reactivity/effects.js b/packages/svelte/src/internal/client/reactivity/effects.js index 16f076edde..149cbd2d38 100644 --- a/packages/svelte/src/internal/client/reactivity/effects.js +++ b/packages/svelte/src/internal/client/reactivity/effects.js @@ -35,7 +35,8 @@ import { INSPECT_EFFECT, HEAD_EFFECT, MAYBE_DIRTY, - EFFECT_HAS_DERIVED + EFFECT_HAS_DERIVED, + BOUNDARY_EFFECT } from '../constants.js'; import { set } from './sources.js'; import * as e from '../errors.js'; @@ -142,7 +143,7 @@ function create_effect(type, fn, sync, push = true) { effect.first === null && effect.nodes_start === null && effect.teardown === null && - (effect.f & EFFECT_HAS_DERIVED) === 0; + (effect.f & (EFFECT_HAS_DERIVED | BOUNDARY_EFFECT)) === 0; if (!inert && !is_root && push) { if (parent_effect !== null) { diff --git a/packages/svelte/tests/runtime-runes/samples/error-boundary-21/Child.svelte b/packages/svelte/tests/runtime-runes/samples/error-boundary-21/Child.svelte new file mode 100644 index 0000000000..ea60542af9 --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/error-boundary-21/Child.svelte @@ -0,0 +1,3 @@ + diff --git a/packages/svelte/tests/runtime-runes/samples/error-boundary-21/_config.js b/packages/svelte/tests/runtime-runes/samples/error-boundary-21/_config.js new file mode 100644 index 0000000000..e301f83e60 --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/error-boundary-21/_config.js @@ -0,0 +1,17 @@ +import { flushSync } from 'svelte'; +import { test } from '../../test'; + +export default test({ + html: '
0
', + mode: ['client'], + test({ assert, target }) { + let btn = target.querySelector('button'); + let div = target.querySelector('div'); + + flushSync(() => { + btn?.click(); + }); + + assert.equal(div?.innerHTML, `1`); + } +}); diff --git a/packages/svelte/tests/runtime-runes/samples/error-boundary-21/main.svelte b/packages/svelte/tests/runtime-runes/samples/error-boundary-21/main.svelte new file mode 100644 index 0000000000..ed3140b1ef --- /dev/null +++ b/packages/svelte/tests/runtime-runes/samples/error-boundary-21/main.svelte @@ -0,0 +1,14 @@ + + + + + + + {#snippet failed()} +
{count}
+ {/snippet} +