fix extract names from ThisExpression

pull/5036/head
Tan Li Hau 5 years ago
parent 1644f207b1
commit aa661cf6cd

@ -120,12 +120,9 @@ export default class Expression {
if (function_expression) {
if (node.type === 'AssignmentExpression') {
deep = node.left.type === 'MemberExpression';
names = deep
? [get_object(node.left).name]
: extract_names(node.left);
names = extract_names(deep ? get_object(node.left) : node.left);
} else if (node.type === 'UpdateExpression') {
const { name } = get_object(node.argument);
names = [name];
names = extract_names(get_object(node.argument));
}
}

@ -0,0 +1,10 @@
export default {
async test({ assert, component, target, window, raf }) {
const [_, btn] = target.querySelectorAll("button");
const clickEvent = new window.MouseEvent("click");
await btn.dispatchEvent(clickEvent);
assert.equal(btn.x, 1);
},
};

@ -0,0 +1,2 @@
<button on:click="{() => { this.x = 1; }}" />
<button on:click="{function () { this.x = 1; }}" />
Loading…
Cancel
Save