mirror of https://github.com/sveltejs/svelte
commit
596716bdd6
@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
'svelte': patch
|
|
||||||
---
|
|
||||||
|
|
||||||
fix: do not dispatch introstart event with animation of animate directive
|
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
<script>
|
||||||
|
import { store } from "./store.svelte.js";
|
||||||
|
|
||||||
|
// This write marks the derived in main.svelte before it has reactions added to it.
|
||||||
|
// This test checks that this does not cause the WAS_MARKED logic to incorrectly skip marking the derived subsequently.
|
||||||
|
store.set("child-init-write", Math.random());
|
||||||
|
</script>
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
import { flushSync } from 'svelte';
|
||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
async test({ assert, target }) {
|
||||||
|
const [show, hide] = target.querySelectorAll('button');
|
||||||
|
|
||||||
|
hide.click();
|
||||||
|
flushSync();
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<button>show</button>
|
||||||
|
<button>hide</button>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
|
||||||
|
show.click();
|
||||||
|
flushSync();
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`
|
||||||
|
<button>show</button>
|
||||||
|
<button>hide</button>
|
||||||
|
<div>visible</div>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
<script>
|
||||||
|
import Child from "./Child.svelte";
|
||||||
|
import { store } from "./store.svelte.js";
|
||||||
|
|
||||||
|
const visible = $derived(store.get("visible"));
|
||||||
|
const visible2 = $derived(visible);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button onclick={() => store.set("visible", true)}>show</button>
|
||||||
|
<button onclick={() => store.set("visible", false)}>hide</button>
|
||||||
|
{#if visible2}
|
||||||
|
<Child />
|
||||||
|
<div>visible</div>
|
||||||
|
{/if}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
class RawStore {
|
||||||
|
values = $state.raw({ visible: true });
|
||||||
|
|
||||||
|
get(key) {
|
||||||
|
return this.values[key];
|
||||||
|
}
|
||||||
|
|
||||||
|
set(key, value) {
|
||||||
|
this.values = { ...this.values, [key]: value };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const store = new RawStore();
|
||||||
Loading…
Reference in new issue