diff --git a/src/runtime/internal/transitions.ts b/src/runtime/internal/transitions.ts index 5591ca1d5127..c2ac4b78cb1a 100644 --- a/src/runtime/internal/transitions.ts +++ b/src/runtime/internal/transitions.ts @@ -24,16 +24,21 @@ function dispatch(node: Element, direction: boolean, kind: 'start' | 'end') { let outros; -export function group_outros() { +function reset_outros() { outros = { remaining: 0, callbacks: [] }; } +export function group_outros() { + reset_outros(); +} + export function check_outros() { if (!outros.remaining) { run_all(outros.callbacks); + reset_outros(); } } diff --git a/test/runtime/samples/each-block-keyed-containing-self-in-if-with-else-branch/Nested.svelte b/test/runtime/samples/each-block-keyed-containing-self-in-if-with-else-branch/Nested.svelte new file mode 100644 index 000000000000..a9831fc1a9c7 --- /dev/null +++ b/test/runtime/samples/each-block-keyed-containing-self-in-if-with-else-branch/Nested.svelte @@ -0,0 +1,5 @@ + + +{item.id} diff --git a/test/runtime/samples/each-block-keyed-containing-self-in-if-with-else-branch/_config.js b/test/runtime/samples/each-block-keyed-containing-self-in-if-with-else-branch/_config.js new file mode 100644 index 000000000000..0aebab391c07 --- /dev/null +++ b/test/runtime/samples/each-block-keyed-containing-self-in-if-with-else-branch/_config.js @@ -0,0 +1,48 @@ +export default { + props: { + list: [ + { id: 1 }, + { id: 2 }, + { id: 3, children: [{ id: 30 }, { id: 31 }, { id: 32 }] }, + ], + activeId: null, + }, + + html: ` + + `, + + test({ assert, component, target }) { + component.activeId = 3; + + assert.htmlEqual(target.innerHTML, ` + + `); + + + component.activeId = null; + + assert.htmlEqual(target.innerHTML, ` + + `); + } +}; diff --git a/test/runtime/samples/each-block-keyed-containing-self-in-if-with-else-branch/main.svelte b/test/runtime/samples/each-block-keyed-containing-self-in-if-with-else-branch/main.svelte new file mode 100644 index 000000000000..5d5c4ba35d12 --- /dev/null +++ b/test/runtime/samples/each-block-keyed-containing-self-in-if-with-else-branch/main.svelte @@ -0,0 +1,19 @@ + + + diff --git a/test/runtime/samples/each-block-keyed-containing-self-in-if/Nested.svelte b/test/runtime/samples/each-block-keyed-containing-self-in-if/Nested.svelte new file mode 100644 index 000000000000..a9831fc1a9c7 --- /dev/null +++ b/test/runtime/samples/each-block-keyed-containing-self-in-if/Nested.svelte @@ -0,0 +1,5 @@ + + +{item.id} diff --git a/test/runtime/samples/each-block-keyed-containing-self-in-if/_config.js b/test/runtime/samples/each-block-keyed-containing-self-in-if/_config.js new file mode 100644 index 000000000000..36d8b3721868 --- /dev/null +++ b/test/runtime/samples/each-block-keyed-containing-self-in-if/_config.js @@ -0,0 +1,48 @@ +export default { + props: { + list: [ + { id: 1 }, + { id: 2 }, + { id: 3, children: [{ id: 30 }, { id: 31 }, { id: 32 }] }, + ], + activeId: null, + }, + + html: ` + + `, + + test({ assert, component, target }) { + component.activeId = 3; + + assert.htmlEqual(target.innerHTML, ` + + `); + + + component.activeId = null; + + assert.htmlEqual(target.innerHTML, ` + + `); + } +}; diff --git a/test/runtime/samples/each-block-keyed-containing-self-in-if/main.svelte b/test/runtime/samples/each-block-keyed-containing-self-in-if/main.svelte new file mode 100644 index 000000000000..c84a733429d6 --- /dev/null +++ b/test/runtime/samples/each-block-keyed-containing-self-in-if/main.svelte @@ -0,0 +1,17 @@ + + +