From 032cab95f533f0c8817131ad1aa02d2fc9b8f4b9 Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Tue, 17 Sep 2019 20:26:49 -0400 Subject: [PATCH] prevent duplicate manipulations --- src/compiler/compile/nodes/shared/Expression.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/compiler/compile/nodes/shared/Expression.ts b/src/compiler/compile/nodes/shared/Expression.ts index 39c1060728..f4ed48a056 100644 --- a/src/compiler/compile/nodes/shared/Expression.ts +++ b/src/compiler/compile/nodes/shared/Expression.ts @@ -81,6 +81,8 @@ export default class Expression { declarations: (Node | Node[])[] = []; uses_context = false; + manipulated: Node; + // todo: owner type constructor(component: Component, owner: Owner, template_scope: TemplateScope, info, lazy?: boolean) { // TODO revert to direct property access in prod? @@ -222,6 +224,10 @@ export default class Expression { // TODO move this into a render-dom wrapper? manipulate(block?: Block) { + // TODO ideally we wouldn't end up calling this method + // multiple times + if (this.manipulated) return this.manipulated; + const { component, declarations, @@ -405,7 +411,7 @@ export default class Expression { }); } - return node; + return (this.manipulated = node); } }