Fix issue of casting a Node[] to a Node in rewrite_props in Component

pull/8442/head
Nguyen Tran 3 years ago
parent d42ca041dd
commit cf44cc161c

@ -1015,7 +1015,7 @@ export default class Component {
let scope = instance_scope; let scope = instance_scope;
walk(this.ast.instance.content, { walk(this.ast.instance.content, {
enter(node: Node) { enter(node: Node, parent: Node, key, index) {
if (regex_contains_term_function.test(node.type)) { if (regex_contains_term_function.test(node.type)) {
return this.skip(); return this.skip();
} }
@ -1138,11 +1138,16 @@ export default class Component {
} }
} }
this.replace(b` if (inserts.length > 0) {
${node.declarations.length ? node : null} parent[key].splice(index + 1, 0, ...inserts);
${ props.length > 0 && b`let { ${props} } = $$props;`} }
${inserts} if (props.length > 0) {
` as any); parent[key].splice(index + 1, 0, b`let { ${props} } = $$props;`);
}
if (node.declarations.length == 0) {
parent[key].splice(index, 1);
}
return this.skip(); return this.skip();
} }
} }

Loading…
Cancel
Save