Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/eight-pans-worry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix : $.component() break transition
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/** @import { TemplateNode, Dom, Effect } from '#client' */
import { EFFECT_TRANSPARENT } from '../../constants.js';
import { block, branch, pause_effect } from '../../reactivity/effects.js';
import { hydrate_next, hydrate_node, hydrating } from '../hydration.js';

Expand Down Expand Up @@ -34,7 +35,7 @@ export function component(node, get_component, render_fn) {
if (component) {
effect = branch(() => render_fn(anchor, component));
}
});
}, EFFECT_TRANSPARENT);

if (hydrating) {
anchor = hydrate_node;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<script>
function fade(_) {
return {
duration: 100,
css: (t) => `opacity: ${t}`
};
}


</script>

<p transition:fade>foo</p>

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { flushSync } from '../../../../src/index-client.js';
import { test } from '../../test';

/**
* $.component() should not break transition
* https://github.com/sveltejs/svelte/issues/13645
*/
export default test({
test({ assert, raf, target }) {
const btn = target.querySelector('button');

// in
btn?.click();
flushSync();
assert.htmlEqual(
target.innerHTML,
'<button>toggle</button><p style="opacity: 0;">foo</p><p style="opacity: 0;">foo</p>'
);

raf.tick(50);
assert.htmlEqual(
target.innerHTML,
'<button>toggle</button><p style="opacity: 0.5;">foo</p><p style="opacity: 0.5;">foo</p>'
);

raf.tick(100);
assert.htmlEqual(
target.innerHTML,
'<button>toggle</button><p style="">foo</p><p style="">foo</p>'
);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<script>
import Foo from './Foo.svelte';
const Comp = { Foo };

let visible = $state(false);
</script>

<button onclick={() => (visible = !visible)}>toggle</button>

{#if visible}
<Foo />
<Comp.Foo />
{/if}