fix: ensure hmr block effects are transparent for transitions (#12384)

* fix: ensure hmr block effects are transparent for transitions

* add test
pull/12391/head
Dominic Gannaway 2 months ago committed by GitHub
parent ce669987a6
commit 125156d7d5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: ensure hmr block effects are transparent for transitions

@ -1,4 +1,5 @@
/** @import { Source, Effect } from '#client' */
import { EFFECT_TRANSPARENT } from '../constants.js';
import { block, branch, destroy_effect } from '../reactivity/effects.js';
import { set_should_intro } from '../render.js';
import { get } from '../runtime.js';
@ -44,7 +45,7 @@ export function hmr(source) {
if (ran) set_should_intro(true);
});
});
}, EFFECT_TRANSPARENT);
ran = true;

@ -0,0 +1,10 @@
<script>
function show(node) {
return {
duration: 500,
css: (t) => `opacity: ${t}`,
}
}
</script>
<div class="red" in:show></div>

@ -0,0 +1,27 @@
import { flushSync } from 'svelte';
import { test } from '../../test';
export default test({
compileOptions: {
dev: true,
hmr: true
},
async test({ assert, target, raf }) {
const [b1] = target.querySelectorAll('button');
b1.click();
flushSync();
b1.click();
flushSync();
raf.tick(0);
raf.tick(250);
const div = /** @type {HTMLDivElement} */ (target.querySelector('.red'));
assert.equal(div.style.opacity, '0.5');
}
});

@ -0,0 +1,14 @@
<script>
import Red from "./Red.svelte"
import Blue from "./Blue.svelte"
const comps = {
Red,
Blue
};
let activeComp = $state("Red")
</script>
<main>
<button onclick={() => activeComp = activeComp === "Red" ? "Blue" : "Red"}>toggle</button>
<svelte:component this={comps[activeComp]} />
</main>
Loading…
Cancel
Save