From 5d34f752b838c72ea69d6138ad2bf1a5c8376f21 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Thu, 15 Nov 2018 22:04:19 -0500 Subject: [PATCH] only apply reactivity to assignments to top-level variables --- src/compile/Component.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/compile/Component.ts b/src/compile/Component.ts index 258ecade2d..03f3196fd8 100644 --- a/src/compile/Component.ts +++ b/src/compile/Component.ts @@ -543,6 +543,8 @@ export default class Component { } }); + const top_scope = scope; + walk(js.content, { enter(node) { if (map.has(node)) { @@ -551,7 +553,15 @@ export default class Component { if (node.type === 'AssignmentExpression') { const { name } = flattenReference(node.left); - code.appendLeft(node.end, `; $$make_dirty('${name}')`); + + if (scope.findOwner(name) === top_scope) { + // TODO verify that it needs to be reactive, i.e. is + // used in the template (and not just in an event + // handler or transition etc) + + // TODO handle arrow function expressions etc + code.appendLeft(node.end, `; $$make_dirty('${name}')`); + } } },