From 153debb6fa18969febf8dfdd6d93fc9b0a4fc551 Mon Sep 17 00:00:00 2001 From: Conduitry Date: Tue, 5 Nov 2019 12:18:59 -0500 Subject: [PATCH] deconflict `block` var used in dev mode (#3854) --- src/compiler/compile/render_dom/Block.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/compiler/compile/render_dom/Block.ts b/src/compiler/compile/render_dom/Block.ts index b268954dd0..c1f67c0a8a 100644 --- a/src/compiler/compile/render_dom/Block.ts +++ b/src/compiler/compile/render_dom/Block.ts @@ -376,6 +376,8 @@ export default class Block { d: ${properties.destroy} }`; + const block = dev && this.get_unique_name('block'); + const body = b` ${Array.from(this.variables.values()).map(({ id, init }) => { return init @@ -387,9 +389,15 @@ export default class Block { ${dev ? b` - const block = ${return_value}; - @dispatch_dev("SvelteRegisterBlock", { block, id: ${this.name || 'create_fragment'}.name, type: "${this.type}", source: "${this.comment ? this.comment.replace(/"/g, '\\"') : ''}", ctx: #ctx }); - return block;` + const ${block} = ${return_value}; + @dispatch_dev("SvelteRegisterBlock", { + block: ${block}, + id: ${this.name || 'create_fragment'}.name, + type: "${this.type}", + source: "${this.comment ? this.comment.replace(/"/g, '\\"') : ''}", + ctx: #ctx + }); + return ${block};` : b` return ${return_value};` }