Skip to content

Commit 03360ce

Browse files
committed
fix(compiler-sfc): treat const reactive() bindings as mutable
1 parent cf67306 commit 03360ce

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

packages/compiler-core/src/transforms/vFor.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export const transformFor = createStructuralDirectiveTransform(
7979

8080
const isStableFragment =
8181
forNode.source.type === NodeTypes.SIMPLE_EXPRESSION &&
82-
forNode.source.constType > ConstantTypes.CAN_SKIP_PATCH
82+
forNode.source.constType > ConstantTypes.NOT_CONSTANT
8383
const fragmentFlag = isStableFragment
8484
? PatchFlags.STABLE_FRAGMENT
8585
: keyProp

packages/compiler-sfc/src/compileScript.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -1036,12 +1036,15 @@ function walkDeclaration(
10361036
)
10371037
if (id.type === 'Identifier') {
10381038
let bindingType
1039-
if (
1039+
const userReactiveBinding = userImportAlias['reactive'] || 'reactive'
1040+
if (isCallOf(init, userReactiveBinding)) {
1041+
// treat reactive() calls as let since it's meant to be mutable
1042+
bindingType = BindingTypes.SETUP_LET
1043+
} else if (
10401044
// if a declaration is a const literal, we can mark it so that
10411045
// the generated render fn code doesn't need to unref() it
10421046
isDefineCall ||
1043-
(isConst &&
1044-
canNeverBeRef(init!, userImportAlias['reactive'] || 'reactive'))
1047+
(isConst && canNeverBeRef(init!, userReactiveBinding))
10451048
) {
10461049
bindingType = BindingTypes.SETUP_CONST
10471050
} else if (isConst) {

0 commit comments

Comments
 (0)