Skip to content

Commit f886bc1

Browse files
authored
fix: handle intro global transition propagation correctly (#9515)
* fix: stop propagating global intros * fix: stop propagating global intros * add test
1 parent e0271f0 commit f886bc1

File tree

4 files changed

+55
-1
lines changed

4 files changed

+55
-1
lines changed

.changeset/shiny-shrimps-march.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: do not propagate global intro transitions

packages/svelte/src/internal/client/transitions.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,8 @@ export function bind_transition(dom, transition_fn, props_fn, direction, global)
460460
);
461461

462462
transition = create_transition(dom, init, direction, transition_effect);
463-
const show_intro = !skip_intro && (direction === 'in' || direction === 'both');
463+
const is_intro = direction === 'in';
464+
const show_intro = !skip_intro && (is_intro || direction === 'both');
464465

465466
if (show_intro) {
466467
transition.payload = transition.init();
@@ -484,6 +485,7 @@ export function bind_transition(dom, transition_fn, props_fn, direction, global)
484485
}
485486
if (
486487
parent === null ||
488+
is_intro ||
487489
(!global &&
488490
(transition_block.type !== IF_BLOCK || parent.type !== IF_BLOCK || parent.current))
489491
) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { flushSync } from '../../../../src/main/main-client';
2+
import { test } from '../../test';
3+
4+
export default test({
5+
html: '<div>0</div><button>toggle</button>',
6+
async test({ assert, component, target, raf }) {
7+
component.value = 2;
8+
9+
const [button] = /** @type {NodeListOf<HTMLButtonElement>} */ (
10+
target.querySelectorAll('button')
11+
);
12+
13+
raf.tick(0);
14+
15+
assert.htmlEqual(target.innerHTML, '<div>2</div><button>toggle</button>');
16+
17+
flushSync(() => {
18+
button.click();
19+
});
20+
21+
raf.tick(0);
22+
23+
assert.htmlEqual(target.innerHTML, '<button>toggle</button>');
24+
}
25+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<script>
2+
export let value = 0;
3+
export let toggle = true;
4+
5+
function foo(node, params) {
6+
return {
7+
duration: 100,
8+
tick: (t, u) => {
9+
node.foo = t;
10+
node.oof = u;
11+
}
12+
};
13+
}
14+
</script>
15+
16+
{#if toggle}
17+
{#key value}
18+
<div in:foo|global>{value}</div>
19+
{/key}
20+
{/if}
21+
22+
<button on:click={() => toggle = !toggle}>toggle</button>

0 commit comments

Comments
 (0)