From 18ac0d272e83116c590f537f93dcf1c8755bcc49 Mon Sep 17 00:00:00 2001 From: Phaqui Date: Sun, 7 Feb 2021 11:20:08 +0100 Subject: [PATCH] Add event listeners to DOM elements before mounting them --- src/compiler/compile/render_dom/Block.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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}