From d2e7b1abcb26890fbd7b8b05933f5eb9af6e7c37 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 26 Apr 2018 21:49:42 -0400 Subject: [PATCH] hmm. work around weird code generation glitch --- src/generators/dom/Block.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/generators/dom/Block.ts b/src/generators/dom/Block.ts index eb803fdba0..390b06461a 100644 --- a/src/generators/dom/Block.ts +++ b/src/generators/dom/Block.ts @@ -179,11 +179,6 @@ export default class Block { this.builders.mount.addLine(`${this.autofocus}.focus();`); } - if (this.maintainContext) { - this.builders.update.addLineAtStart(`ctx = _ctx;`); - this.hasUpdateMethod = true; - } - // minor hack – we need to ensure that any {{{triples}}} are detached first this.builders.unmount.addBlockAtStart(this.builders.detachRaw.toString()); @@ -242,12 +237,13 @@ export default class Block { `); } - if (this.hasUpdateMethod) { - if (this.builders.update.isEmpty()) { + if (this.hasUpdateMethod || this.maintainContext) { + if (this.builders.update.isEmpty() && !this.maintainContext) { properties.addBlock(`p: @noop,`); } else { properties.addBlock(deindent` p: function update(changed, ${this.maintainContext ? '_ctx' : 'ctx'}) { + ${this.maintainContext && `ctx = _ctx;`} ${this.builders.update} }, `);