Repository: sveltejs/svelte (JavaScript) — Bug Fix

Issue:
Uncaught ReferenceError: current is not defined
### Steps to reproduce
 1. Open gist: https://svelte.technology/repl?version=2.9.3&gist=906410361695020ab832e410780acc69
 2. Type something in the text box
 3. Look at the console for the error


This only happens when the else block has a nested component.
And, only when `nestedTransitions == true`.

Seems like it is referencing an undefined variable called `current` in Else block's `p: update()` method.
Uncaught ReferenceError: current is not defined
### Steps to reproduce
 1. Open gist: https://svelte.technology/repl?version=2.9.3&gist=906410361695020ab832e410780acc69
 2. Type something in the text box
 3. Look at the console for the error


This only happens when the else block has a nested component.
And, only when `nestedTransitions == true`.

Seems like it is referencing an undefined variable called `current` in Else block's `p: update()` method.


Discussion:
I'm also running into `Uncaught ReferenceError: current is not defined` errors, but I'm not using transitions at all. It happens in a larger application I'm working on now, but so far I haven't been able to create a minimal example which triggers it.
I'm also running into `Uncaught ReferenceError: current is not defined` errors, but I'm not using transitions at all. It happens in a larger application I'm working on now, but so far I haven't been able to create a minimal example which triggers it.

Resolving patch:
diff --git a/src/compile/nodes/IfBlock.ts b/src/compile/nodes/IfBlock.ts
--- a/src/compile/nodes/IfBlock.ts
+++ b/src/compile/nodes/IfBlock.ts
@@ -90,6 +90,9 @@ export default class IfBlock extends Node {
 					dynamic = true;
 					block.addDependencies(node.else.block.dependencies);
 				}
+
+				if (node.else.block.hasIntros) hasIntros = true;
+				if (node.else.block.hasOutros) hasOutros = true;
 			}
 		}
 


Test patch:
diff --git a/test/runtime/samples/if-block-no-outro-else-with-outro/Widget.html b/test/runtime/samples/if-block-no-outro-else-with-outro/Widget.html
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/if-block-no-outro-else-with-outro/Widget.html
@@ -0,0 +1 @@
+<div>A wild component appears</div>
\ No newline at end of file
diff --git a/test/runtime/samples/if-block-no-outro-else-with-outro/_config.js b/test/runtime/samples/if-block-no-outro-else-with-outro/_config.js
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/if-block-no-outro-else-with-outro/_config.js
@@ -0,0 +1,10 @@
+export default {
+	nestedTransitions: true,
+
+	html: '<div>A wild component appears</div><p>x</p><input type="text">',
+
+	test(assert, component, target) {
+		component.set({ x: 'y' });
+		assert.htmlEqual(target.innerHTML, '<div>A wild component appears</div><p>y</p><input type="text">');
+	},
+};
diff --git a/test/runtime/samples/if-block-no-outro-else-with-outro/main.html b/test/runtime/samples/if-block-no-outro-else-with-outro/main.html
new file mode 100644
--- /dev/null
+++ b/test/runtime/samples/if-block-no-outro-else-with-outro/main.html
@@ -0,0 +1,21 @@
+{#if foo}
+	<p>foo</p>
+{:else}
+	<Widget/>
+	<p>{x}</p>
+	<input type="text" bind:value=x />
+{/if}
+
+<script>
+	export default {
+		components: {
+			Widget: './Widget.html'
+		},
+
+		data() {
+			return {
+				x: 'x'
+			};
+		}
+	};
+</script>
\ No newline at end of file