diff --git a/src/compiler/compile/utils/get_object.ts b/src/compiler/compile/utils/get_object.ts index 863bfb0d61..75b1964a13 100644 --- a/src/compiler/compile/utils/get_object.ts +++ b/src/compiler/compile/utils/get_object.ts @@ -1,6 +1,28 @@ -import { Node, Identifier } from 'estree'; +import { + Node, + Identifier, + ArrayExpression, + ObjectExpression, + ThisExpression, + ObjectPattern, + ArrayPattern, + Literal, +} from "estree"; -export default function get_object(node: Node): Identifier { - while (node.type === 'MemberExpression') node = node.object; - return node as Identifier; +type ObjectType = + | Identifier + | ThisExpression + | ArrayExpression + | ObjectExpression + | ArrayPattern + | ObjectPattern + | Literal; + +export default function get_object(node: Node): ObjectType { + while (true) { + if (node.type === "MemberExpression") node = node.object; + else if (node.type === "CallExpression") node = node.callee; + else break; + } + return node as ObjectType; } diff --git a/test/runtime/samples/binding-input-text-map/_config.js b/test/runtime/samples/binding-input-text-map/_config.js new file mode 100644 index 0000000000..8c58a84d5c --- /dev/null +++ b/test/runtime/samples/binding-input-text-map/_config.js @@ -0,0 +1,24 @@ +export default { + html: ` + + `, + + ssrHtml: ` + + `, + + async test({ assert, component, target, window }) { + const input = target.querySelector('input'); + assert.equal(input.value, '50'); + + component.map.get(component.id).x = 30; + component.map = component.map; + assert.equal(input.value, '30'); + + input.value = '42'; + await input.dispatchEvent(new window.Event('input')); + + assert.equal(input.value, '42'); + assert.equal(component.map.get(component.id).x, '42') + } +}; diff --git a/test/runtime/samples/binding-input-text-map/main.svelte b/test/runtime/samples/binding-input-text-map/main.svelte new file mode 100644 index 0000000000..9c447d0f28 --- /dev/null +++ b/test/runtime/samples/binding-input-text-map/main.svelte @@ -0,0 +1,7 @@ + + +