add braces around instrumented block-less if statements etc

pull/1839/head
Rich Harris 7 years ago
parent 2f49125441
commit 50c2b5b019

@ -163,7 +163,7 @@ export default function dom(
}
},
leave(node) {
leave(node, parent) {
if (map.has(node)) {
scope = scope.parent;
}
@ -211,6 +211,9 @@ export default function dom(
} else {
code.prependRight(node.start, `${insert}; `);
}
} else if (parent && /(If|For(In|Of)?|While)Statement/.test(parent.type) && node.type !== 'BlockStatement') {
code.prependRight(node.start, '{ ');
code.appendLeft(node.end, `${code.original[node.end - 1] === ';' ? '' : ';'} ${insert}; }`);
} else {
code.appendLeft(node.end, `${code.original[node.end - 1] === ';' ? '' : ';'} ${insert};`);
}

Loading…
Cancel
Save