fix renamed instance exports (#2253)

pull/2261/head
Conduitry 6 years ago
parent 21d56c9ee3
commit 6354c66890

@ -834,8 +834,8 @@ export default class Component {
current_group.declarators.push(declarator);
}
if (variable.name !== variable.export_name) {
code.prependRight(declarator.id.start, `${variable.export_name}:`)
if (variable.writable && variable.name !== variable.export_name) {
code.prependRight(declarator.id.start, `${variable.export_name}: `)
}
if (next) {

@ -114,7 +114,7 @@ export default function dom(
if (component.component_options.accessors) {
body.push(deindent`
set ${x.export_name}(${x.name}) {
this.$set({ ${x.name} });
this.$set({ ${x.name === x.export_name ? x.name : `${x.export_name}: ${x.name}`} });
@flush();
}
`);

@ -0,0 +1,10 @@
export default {
test({ assert, component }) {
assert.equal(component.bar1, 42);
assert.equal(component.bar2, 42);
component.bar1 = 100;
component.bar2 = 100;
assert.equal(component.bar1, 42);
assert.equal(component.bar2, 100);
}
};

@ -0,0 +1,5 @@
<script>
const foo1 = 42;
let foo2 = 42;
export { foo1 as bar1, foo2 as bar2 };
</script>
Loading…
Cancel
Save