From aa528e5dba4386754fad49135374848850d19c05 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Sat, 8 Dec 2018 22:17:13 -0500 Subject: [PATCH] fix assignment to computed property --- src/compile/render-dom/index.ts | 4 ++-- .../samples/assignment-to-computed-property/_config.js | 5 +++++ .../samples/assignment-to-computed-property/main.html | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 test/runtime/samples/assignment-to-computed-property/_config.js create mode 100644 test/runtime/samples/assignment-to-computed-property/main.html diff --git a/src/compile/render-dom/index.ts b/src/compile/render-dom/index.ts index cd87e295ed..472d51991e 100644 --- a/src/compile/render-dom/index.ts +++ b/src/compile/render-dom/index.ts @@ -5,9 +5,9 @@ import Component from '../Component'; import Renderer from './Renderer'; import { CompileOptions } from '../../interfaces'; import { walk } from 'estree-walker'; -import flattenReference from '../../utils/flattenReference'; import stringifyProps from '../../utils/stringifyProps'; import addToSet from '../../utils/addToSet'; +import getObject from '../../utils/getObject'; export default function dom( component: Component, @@ -160,7 +160,7 @@ export default function dom( } if (node.type === 'AssignmentExpression') { - const { name } = flattenReference(node.left); + const { name } = getObject(node.left); if (scope.findOwner(name) === component.instance_scope) { component.instrument(node, parent, name, false); diff --git a/test/runtime/samples/assignment-to-computed-property/_config.js b/test/runtime/samples/assignment-to-computed-property/_config.js new file mode 100644 index 0000000000..7ba090abe9 --- /dev/null +++ b/test/runtime/samples/assignment-to-computed-property/_config.js @@ -0,0 +1,5 @@ +export default { + test({ assert, component }) { + assert.deepEqual(component.foo, { baz: 1 }); + } +}; \ No newline at end of file diff --git a/test/runtime/samples/assignment-to-computed-property/main.html b/test/runtime/samples/assignment-to-computed-property/main.html new file mode 100644 index 0000000000..8bbe2422ed --- /dev/null +++ b/test/runtime/samples/assignment-to-computed-property/main.html @@ -0,0 +1,5 @@ + \ No newline at end of file