fix(compiler-sfc): treat const reactive() bindings as mutable
This commit is contained in:
parent
cf67306032
commit
03360cefa1
@ -79,7 +79,7 @@ export const transformFor = createStructuralDirectiveTransform(
|
|||||||
|
|
||||||
const isStableFragment =
|
const isStableFragment =
|
||||||
forNode.source.type === NodeTypes.SIMPLE_EXPRESSION &&
|
forNode.source.type === NodeTypes.SIMPLE_EXPRESSION &&
|
||||||
forNode.source.constType > ConstantTypes.CAN_SKIP_PATCH
|
forNode.source.constType > ConstantTypes.NOT_CONSTANT
|
||||||
const fragmentFlag = isStableFragment
|
const fragmentFlag = isStableFragment
|
||||||
? PatchFlags.STABLE_FRAGMENT
|
? PatchFlags.STABLE_FRAGMENT
|
||||||
: keyProp
|
: keyProp
|
||||||
|
@ -1036,12 +1036,15 @@ function walkDeclaration(
|
|||||||
)
|
)
|
||||||
if (id.type === 'Identifier') {
|
if (id.type === 'Identifier') {
|
||||||
let bindingType
|
let bindingType
|
||||||
if (
|
const userReactiveBinding = userImportAlias['reactive'] || 'reactive'
|
||||||
|
if (isCallOf(init, userReactiveBinding)) {
|
||||||
|
// treat reactive() calls as let since it's meant to be mutable
|
||||||
|
bindingType = BindingTypes.SETUP_LET
|
||||||
|
} else if (
|
||||||
// if a declaration is a const literal, we can mark it so that
|
// if a declaration is a const literal, we can mark it so that
|
||||||
// the generated render fn code doesn't need to unref() it
|
// the generated render fn code doesn't need to unref() it
|
||||||
isDefineCall ||
|
isDefineCall ||
|
||||||
(isConst &&
|
(isConst && canNeverBeRef(init!, userReactiveBinding))
|
||||||
canNeverBeRef(init!, userImportAlias['reactive'] || 'reactive'))
|
|
||||||
) {
|
) {
|
||||||
bindingType = BindingTypes.SETUP_CONST
|
bindingType = BindingTypes.SETUP_CONST
|
||||||
} else if (isConst) {
|
} else if (isConst) {
|
||||||
|
Loading…
Reference in New Issue
Block a user