Skip to content
Open
Show file tree
Hide file tree
Changes from all 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/nasty-candles-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: avoid forward the transition property inside EffectNodes in HMR
8 changes: 6 additions & 2 deletions packages/svelte/src/internal/client/dev/hmr.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { hydrate_node, hydrating } from '../dom/hydration.js';
import { block, branch, destroy_effect } from '../reactivity/effects.js';
import { set, source } from '../reactivity/sources.js';
import { set_should_intro } from '../render.js';
import { active_effect, get } from '../runtime.js';
import { get } from '../runtime.js';
import { assign_nodes } from '../dom/template.js';

/**
* @template {(anchor: Comment, props: any) => any} Component
Expand Down Expand Up @@ -60,7 +61,10 @@ export function hmr(fn) {
// Forward the nodes from the inner effect to the outer active effect which would
// get them if the HMR wrapper wasn't there. Do this inside the block not outside
// so that HMR updates to the component will also update the nodes on the active effect.
/** @type {Effect} */ (active_effect).nodes = effect.nodes;
if (effect.nodes) {
// only forward the start and end node
assign_nodes(effect.nodes.start, effect.nodes.end);

@vercel vercel Bot Jul 2, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

HMR node forwarding via assign_nodes only runs on first render, leaving the persistent block effect's start/end pointing at destroyed DOM after a component hot-update.

Fix on Vercel

}
}, EFFECT_TRANSPARENT);

ran = true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script >
function fade(_) {
return {
delay: 100,
duration: 100,
css: (t) => `opacity: ${t}`
};
}
</script>
<p
transition:fade
onintrostart={() => console.log('introstart')}
onintroend={() => console.log('introend')}
onoutrostart={() => console.log('outrostart')}
onoutroend={() => console.log('outroend')}
>delayed fade</p>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { flushSync, tick } from 'svelte';
import { test } from '../../test';

export default test({
compileOptions: {
dev: true,
hmr: true
},
test({ assert, raf, target, logs }) {
const [btn] = target.querySelectorAll('button');

// in
flushSync(() => btn.click());
assert.deepEqual(logs, []);
raf.tick(1);
assert.deepEqual(logs, []);

raf.tick(100);
assert.deepEqual(logs, ['introstart']);

raf.tick(200);
assert.deepEqual(logs, ['introstart', 'introend']);

// out
flushSync(() => btn.click());
assert.deepEqual(logs, ['introstart', 'introend']);
raf.tick(201);
assert.deepEqual(logs, ['introstart', 'introend']);

raf.tick(300);
assert.deepEqual(logs, ['introstart', 'introend', 'outrostart']);

raf.tick(400);
assert.deepEqual(logs, ['introstart', 'introend', 'outrostart', 'outroend']);
}
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script>
import Drawer from "./Drawer.svelte"


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

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

{#if visible}
<Drawer />
{/if}