Skip to content

Commit

Permalink
fix: handle intro global transition propagation correctly (#9515)
Browse files Browse the repository at this point in the history
* fix: stop propagating global intros

* fix: stop propagating global intros

* add test
  • Loading branch information
trueadm authored Nov 17, 2023
1 parent e0271f0 commit f886bc1
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/shiny-shrimps-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: do not propagate global intro transitions
4 changes: 3 additions & 1 deletion packages/svelte/src/internal/client/transitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,8 @@ export function bind_transition(dom, transition_fn, props_fn, direction, global)
);

transition = create_transition(dom, init, direction, transition_effect);
const show_intro = !skip_intro && (direction === 'in' || direction === 'both');
const is_intro = direction === 'in';
const show_intro = !skip_intro && (is_intro || direction === 'both');

if (show_intro) {
transition.payload = transition.init();
Expand All @@ -484,6 +485,7 @@ export function bind_transition(dom, transition_fn, props_fn, direction, global)
}
if (
parent === null ||
is_intro ||
(!global &&
(transition_block.type !== IF_BLOCK || parent.type !== IF_BLOCK || parent.current))
) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { flushSync } from '../../../../src/main/main-client';
import { test } from '../../test';

export default test({
html: '<div>0</div><button>toggle</button>',
async test({ assert, component, target, raf }) {
component.value = 2;

const [button] = /** @type {NodeListOf<HTMLButtonElement>} */ (
target.querySelectorAll('button')
);

raf.tick(0);

assert.htmlEqual(target.innerHTML, '<div>2</div><button>toggle</button>');

flushSync(() => {
button.click();
});

raf.tick(0);

assert.htmlEqual(target.innerHTML, '<button>toggle</button>');
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<script>
export let value = 0;
export let toggle = true;
function foo(node, params) {
return {
duration: 100,
tick: (t, u) => {
node.foo = t;
node.oof = u;
}
};
}
</script>

{#if toggle}
{#key value}
<div in:foo|global>{value}</div>
{/key}
{/if}

<button on:click={() => toggle = !toggle}>toggle</button>

1 comment on commit f886bc1

@vercel
Copy link

@vercel vercel bot commented on f886bc1 Nov 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

svelte-5-preview – ./sites/svelte-5-preview

svelte-octane.vercel.app
svelte-5-preview-svelte.vercel.app
svelte-5-preview.vercel.app
svelte-5-preview-git-main-svelte.vercel.app

Please sign in to comment.