function c() {}
class d {}
-return { aa, bb, cc, dd, a, b, c, d, xx, x }
+return { get aa() { return aa }, bb, cc, dd, get a() { return a }, b, c, d, xx, x }
}
}"
let c = () => {}
let d
-return { foo, a, b, c, d, ref, shallowRef }
+return { foo, a, b, get c() { return c }, get d() { return d }, ref, shallowRef }
}
}"
let c = () => {}
let d
-return { foo, a, b, c, d }
+return { foo, a, b, get c() { return c }, get d() { return d } }
}
}"
let b = 200
let foo = 300
-return { a, b, foo }
+return { get a() { return a }, get b() { return b }, get foo() { return foo } }
}
}"
class dd {}
</script>
`)
- expect(content).toMatch('return { aa, bb, cc, dd, a, b, c, d, xx, x }')
+ expect(content).toMatch(
+ 'return { get aa() { return aa }, bb, cc, dd, get a() { return a }, b, c, d, xx, x }'
+ )
expect(bindings).toStrictEqual({
x: BindingTypes.SETUP_MAYBE_REF,
a: BindingTypes.SETUP_LET,
// normal declarations left untouched
expect(content).toMatch(`let c = () => {}`)
expect(content).toMatch(`let d`)
- expect(content).toMatch(`return { foo, a, b, c, d, ref, shallowRef }`)
+ expect(content).toMatch(
+ `return { foo, a, b, get c() { return c }, get d() { return d }, ref, shallowRef }`
+ )
assertCode(content)
expect(bindings).toStrictEqual({
foo: BindingTypes.SETUP_REF,
allBindings[key] = true
}
}
- returned = `{ ${Object.keys(allBindings).join(', ')} }`
+ returned = `{ `
+ for (const key in allBindings) {
+ if (bindingMetadata[key] === BindingTypes.SETUP_LET) {
+ returned += `get ${key}() { return ${key} }, `
+ } else {
+ returned += `${key}, `
+ }
+ }
+ returned = returned.replace(/, $/, '') + ` }`
} else {
// inline mode
if (sfc.template && !sfc.template.src) {