Skip to content

Commit 2f08e34

Browse files
committed
prevent outro groups getting muddled up - fixes #2086
1 parent 65b28ed commit 2f08e34

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

src/runtime/internal/transitions.ts

+12-10
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,17 @@ let outros;
2828

2929
export function group_outros() {
3030
outros = {
31-
remaining: 0,
32-
callbacks: []
31+
r: 0, // remaining outros
32+
c: [], // callbacks
33+
p: outros // parent group
3334
};
3435
}
3536

3637
export function check_outros() {
37-
if (!outros.remaining) {
38-
run_all(outros.callbacks);
38+
if (!outros.r) {
39+
run_all(outros.c);
3940
}
41+
outros = outros.p;
4042
}
4143

4244
export function transition_in(block, local?: 0 | 1) {
@@ -51,7 +53,7 @@ export function transition_out(block, local: 0 | 1, detach: 0 | 1, callback) {
5153
if (outroing.has(block)) return;
5254
outroing.add(block);
5355

54-
outros.callbacks.push(() => {
56+
outros.c.push(() => {
5557
outroing.delete(block);
5658
if (callback) {
5759
if (detach) block.d(1);
@@ -153,7 +155,7 @@ export function create_out_transition(node: Element & ElementCSSInlineStyle, fn:
153155

154156
const group = outros;
155157

156-
group.remaining += 1;
158+
group.r += 1;
157159

158160
function go() {
159161
const {
@@ -178,10 +180,10 @@ export function create_out_transition(node: Element & ElementCSSInlineStyle, fn:
178180

179181
dispatch(node, false, 'end');
180182

181-
if (!--group.remaining) {
183+
if (!--group.r) {
182184
// this will result in `end()` being called,
183185
// so we don't need to clean up here
184-
run_all(group.callbacks);
186+
run_all(group.c);
185187
}
186188

187189
return false;
@@ -266,7 +268,7 @@ export function create_bidirectional_transition(node: Element & ElementCSSInline
266268
if (!b) {
267269
// @ts-ignore todo: improve typings
268270
program.group = outros;
269-
outros.remaining += 1;
271+
outros.r += 1;
270272
}
271273

272274
if (running_program) {
@@ -309,7 +311,7 @@ export function create_bidirectional_transition(node: Element & ElementCSSInline
309311
clear_animation();
310312
} else {
311313
// outro — needs to be coordinated
312-
if (!--running_program.group.remaining) run_all(running_program.group.callbacks);
314+
if (!--running_program.group.r) run_all(running_program.group.c);
313315
}
314316
}
315317

test/runtime/samples/each-block-keyed-nested/_config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ export default {
77
component.desks = [
88
{
99
id: 1,
10-
teams: [{ id: 2 }]
10+
teams: []
1111
}
1212
];
1313

14-
assert.htmlEqual(target.innerHTML, '2');
14+
assert.htmlEqual(target.innerHTML, '');
1515
}
1616
};

0 commit comments

Comments
 (0)