diff --git a/src/compile/nodes/IfBlock.ts b/src/compile/nodes/IfBlock.ts
index 2a5a49af16..eef654b90b 100644
--- a/src/compile/nodes/IfBlock.ts
+++ b/src/compile/nodes/IfBlock.ts
@@ -139,9 +139,10 @@ export default class IfBlock extends Node {
 				this.buildCompoundWithOutros(block, parentNode, parentNodes, branches, dynamic, vars);
 
 				if (this.compiler.options.nestedTransitions) {
-					block.builders.outro.addLine(
-						`${name}.o(#outrocallback);`
-					);
+					block.builders.outro.addBlock(deindent`
+						if (${name}) ${name}.o(#outrocallback);
+						else #outrocallback();
+					`);
 				}
 			} else {
 				this.buildCompound(block, parentNode, parentNodes, branches, dynamic, vars);
diff --git a/test/runtime/samples/if-block-outro-nested-else/Component.html b/test/runtime/samples/if-block-outro-nested-else/Component.html
new file mode 100644
index 0000000000..281c6866c3
--- /dev/null
+++ b/test/runtime/samples/if-block-outro-nested-else/Component.html
@@ -0,0 +1 @@
+<div></div>
\ No newline at end of file
diff --git a/test/runtime/samples/if-block-outro-nested-else/_config.js b/test/runtime/samples/if-block-outro-nested-else/_config.js
new file mode 100644
index 0000000000..4fe5eaa926
--- /dev/null
+++ b/test/runtime/samples/if-block-outro-nested-else/_config.js
@@ -0,0 +1,8 @@
+export default {
+	nestedTransitions: true,
+
+	test ( assert, component, target ) {
+		// Would cause "TypeError: Cannot read property 'o' of undefined"
+		component.set({ foo: false });
+	}
+};
diff --git a/test/runtime/samples/if-block-outro-nested-else/main.html b/test/runtime/samples/if-block-outro-nested-else/main.html
new file mode 100644
index 0000000000..02e000b3c3
--- /dev/null
+++ b/test/runtime/samples/if-block-outro-nested-else/main.html
@@ -0,0 +1,16 @@
+{#if foo}
+	{#if false}
+		<Component/>
+	{:elseif false}
+		<Component/>
+	{/if}
+{/if}
+
+<script>
+	export default {
+		components: {
+			Component: './Component.html',
+		},
+		data: () => ({ foo: true }),
+	}
+</script>