Skip to content

Commit

Permalink
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -540,6 +540,16 @@ describe('compiler: expression transform', () => {
const { code } = compileWithBindingMetadata(`<div>{{ literal }}</div>`, {
inline: true
})
expect(code).toMatch(`toDisplayString(literal)`)
// #7973 should skip patch for literal const
expect(code).not.toMatch(
`${PatchFlags.TEXT} /* ${PatchFlagNames[PatchFlags.TEXT]} */`
)
})

test('literal const handling, non-inline mode', () => {
const { code } = compileWithBindingMetadata(`<div>{{ literal }}</div>`)
expect(code).toMatch(`toDisplayString(literal)`)
// #7973 should skip patch for literal const
expect(code).not.toMatch(
`${PatchFlags.TEXT} /* ${PatchFlagNames[PatchFlags.TEXT]} */`
2 changes: 2 additions & 0 deletions packages/compiler-core/src/transforms/transformExpression.ts
Original file line number Diff line number Diff line change
@@ -202,6 +202,8 @@ export function processExpression(
return `$setup.${raw}`
} else if (type === BindingTypes.PROPS_ALIASED) {
return `$props['${bindingMetadata.__propsAliases![raw]}']`
} else if (type === BindingTypes.LITERAL_CONST) {
return raw
} else if (type) {
return `$${type}.${raw}`
}

0 comments on commit 6bda4b6

Please sign in to comment.