mirror of https://github.com/sveltejs/svelte
fix: improve await block behaviour in non-runes mode (#12179)
Fixes #12166. Turns out that the recent refactors here negated the fact that non-runes mode uses a slightly different source signal that has different equality rules. I also updated the docs in this PR too to reflect that only plain objects and arrays are proxied.pull/12164/head
parent
e3d8ee6c6d
commit
59f7bd6f9f
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"svelte": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: improve await block behaviour in non-runes mode
|
@ -0,0 +1,8 @@
|
|||||||
|
<script>
|
||||||
|
export let card;
|
||||||
|
export let onfav;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<button on:click={onfav}>
|
||||||
|
{card.x}
|
||||||
|
</button>
|
@ -0,0 +1,20 @@
|
|||||||
|
import { test } from '../../test';
|
||||||
|
|
||||||
|
export default test({
|
||||||
|
async test({ assert, target }) {
|
||||||
|
await Promise.resolve();
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`<button>1</button><button>2</button><button>3</button><button>4</button>\n-------`
|
||||||
|
);
|
||||||
|
|
||||||
|
const [b1] = target.querySelectorAll('button');
|
||||||
|
|
||||||
|
b1.click();
|
||||||
|
await Promise.resolve();
|
||||||
|
assert.htmlEqual(
|
||||||
|
target.innerHTML,
|
||||||
|
`<button>2</button><button>3</button><button>4</button>\n-------\n<button>1</button>`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,30 @@
|
|||||||
|
<script>
|
||||||
|
import Card from './Card.svelte'
|
||||||
|
|
||||||
|
const x = [{
|
||||||
|
fav: false,
|
||||||
|
x: 1
|
||||||
|
}, {
|
||||||
|
fav: false,
|
||||||
|
x: 2
|
||||||
|
}, {
|
||||||
|
fav: false,
|
||||||
|
x: 3
|
||||||
|
}, {
|
||||||
|
fav: false,
|
||||||
|
x: 4
|
||||||
|
}];
|
||||||
|
|
||||||
|
let p_cards = Promise.resolve(JSON.parse(JSON.stringify(x)));
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#await p_cards then cards}
|
||||||
|
{#each cards.filter((card) => !card.fav) as card}
|
||||||
|
<Card {card} onfav={() => {card.fav = !card.fav}}></Card>
|
||||||
|
{/each}
|
||||||
|
-------
|
||||||
|
{#each cards.filter((card) => card.fav) as card}
|
||||||
|
<Card {card} onfav={() => {card.fav = !card.fav}}></Card>
|
||||||
|
{/each}
|
||||||
|
{/await}
|
||||||
|
|
Loading…
Reference in new issue