diff --git a/src/compiler/compile/render_dom/Block.ts b/src/compiler/compile/render_dom/Block.ts index c511bb0b9509..61dc00295156 100644 --- a/src/compiler/compile/render_dom/Block.ts +++ b/src/compiler/compile/render_dom/Block.ts @@ -459,7 +459,7 @@ export default class Block { this.add_variable(dispose); if (this.event_listeners.length === 1) { - this.chunks.mount.push( + this.chunks.mount.unshift( b` if (!#mounted) { ${dispose} = ${this.event_listeners[0]}; @@ -472,7 +472,7 @@ export default class Block { b`${dispose}();` ); } else { - this.chunks.mount.push(b` + this.chunks.mount.unshift(b` if (!#mounted) { ${dispose} = [ ${this.event_listeners}