} from '../../src'
import { transformIf } from '../../src/transforms/vIf'
import { transformExpression } from '../../src/transforms/transformExpression'
+import { PatchFlagNames, PatchFlags } from '../../../shared/src'
function parseWithExpressionTransform(
template: string,
setup: BindingTypes.SETUP_MAYBE_REF,
setupConst: BindingTypes.SETUP_CONST,
data: BindingTypes.DATA,
- options: BindingTypes.OPTIONS
+ options: BindingTypes.OPTIONS,
+ reactive: BindingTypes.SETUP_REACTIVE_CONST,
+ literal: BindingTypes.LITERAL_CONST
}
function compileWithBindingMetadata(
expect(code).toMatch(`_ctx.options`)
expect(code).toMatchSnapshot()
})
+
+ test('literal const handling', () => {
+ const { code } = compileWithBindingMetadata(`<div>{{ literal }}</div>`, {
+ inline: true
+ })
+ // #7973 should skip patch for literal const
+ expect(code).not.toMatch(
+ `${PatchFlags.TEXT} /* ${PatchFlagNames[PatchFlags.TEXT]} */`
+ )
+ })
+
+ test('reactive const handling', () => {
+ const { code } = compileWithBindingMetadata(`<div>{{ reactive }}</div>`, {
+ inline: true
+ })
+ // #7973 should not skip patch for reactive const
+ expect(code).toMatch(
+ `${PatchFlags.TEXT} /* ${PatchFlagNames[PatchFlags.TEXT]} */`
+ )
+ })
})
})
const isDestructureAssignment =
parent && isInDestructureAssignment(parent, parentStack)
- if (isConst(type) || localVars[raw]) {
+ if (
+ isConst(type) ||
+ type === BindingTypes.SETUP_REACTIVE_CONST ||
+ localVars[raw]
+ ) {
return raw
} else if (type === BindingTypes.SETUP_REF) {
return `${raw}.value`
function isConst(type: unknown) {
return (
- type === BindingTypes.SETUP_CONST ||
- type === BindingTypes.LITERAL_CONST ||
- type === BindingTypes.SETUP_REACTIVE_CONST
+ type === BindingTypes.SETUP_CONST || type === BindingTypes.LITERAL_CONST
)
}