diff --git a/packages/compiler-core/__tests__/transforms/__snapshots__/vMemo.spec.ts.snap b/packages/compiler-core/__tests__/transforms/__snapshots__/vMemo.spec.ts.snap
index 220bc177418..86e0b3d2fd5 100644
--- a/packages/compiler-core/__tests__/transforms/__snapshots__/vMemo.spec.ts.snap
+++ b/packages/compiler-core/__tests__/transforms/__snapshots__/vMemo.spec.ts.snap
@@ -1,5 +1,23 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
+exports[`compiler: v-memo transform > element v-for key expression prefixing + v-memo 1`] = `
+"import { renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, isMemoSame as _isMemoSame, withMemo as _withMemo } from "vue"
+
+export function render(_ctx, _cache) {
+ return (_openBlock(), _createElementBlock("div", null, [
+ (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(_ctx.tableData, (data, __, ___, _cached) => {
+ const _memo = (_ctx.getLetter(data))
+ if (_cached && _cached.key === _ctx.getId(data) && _isMemoSame(_cached, _memo)) return _cached
+ const _item = (_openBlock(), _createElementBlock("span", {
+ key: _ctx.getId(data)
+ }))
+ _item.memo = _memo
+ return _item
+ }, _cache, 0), 128 /* KEYED_FRAGMENT */))
+ ]))
+}"
+`;
+
exports[`compiler: v-memo transform > on component 1`] = `
"import { resolveComponent as _resolveComponent, createVNode as _createVNode, withMemo as _withMemo, openBlock as _openBlock, createElementBlock as _createElementBlock } from "vue"
diff --git a/packages/compiler-core/__tests__/transforms/vFor.spec.ts b/packages/compiler-core/__tests__/transforms/vFor.spec.ts
index d0aecc4e0da..fead2476ac5 100644
--- a/packages/compiler-core/__tests__/transforms/vFor.spec.ts
+++ b/packages/compiler-core/__tests__/transforms/vFor.spec.ts
@@ -667,29 +667,6 @@ describe('compiler: v-for', () => {
})
})
- test('element v-for key expression prefixing + v-memo', () => {
- const {
- node: { codegenNode },
- } = parseWithForTransform(
- '',
- { prefixIdentifiers: true },
- )
- const keyExp =
- // @ts-expect-error
- codegenNode.children.arguments[1].body.body[1].children[2]
- expect(keyExp).toMatchObject({
- type: NodeTypes.COMPOUND_EXPRESSION,
- children: [
- // should prefix outer scope references
- { content: `_ctx.getId` },
- `(`,
- // should NOT prefix in scope variables
- { content: `data` },
- `)`,
- ],
- })
- })
-
test('template v-for key no prefixing on attribute key', () => {
const {
node: { codegenNode },
diff --git a/packages/compiler-core/__tests__/transforms/vMemo.spec.ts b/packages/compiler-core/__tests__/transforms/vMemo.spec.ts
index ba6752241eb..41e7d922ebe 100644
--- a/packages/compiler-core/__tests__/transforms/vMemo.spec.ts
+++ b/packages/compiler-core/__tests__/transforms/vMemo.spec.ts
@@ -1,5 +1,4 @@
-import { NodeTypes, baseCompile } from '../../src'
-import { parseWithForTransform } from './vFor.spec'
+import { baseCompile } from '../../src'
describe('compiler: v-memo transform', () => {
function compile(content: string) {
@@ -56,25 +55,10 @@ describe('compiler: v-memo transform', () => {
})
test('element v-for key expression prefixing + v-memo', () => {
- const {
- node: { codegenNode },
- } = parseWithForTransform(
- '',
- { prefixIdentifiers: true },
- )
- const keyExp =
- // @ts-expect-error
- codegenNode.children.arguments[1].body.body[1].children[2]
- expect(keyExp).toMatchObject({
- type: NodeTypes.COMPOUND_EXPRESSION,
- children: [
- // should prefix outer scope references
- { content: `_ctx.getId` },
- `(`,
- // should NOT prefix in scope variables
- { content: `data` },
- `)`,
- ],
- })
+ expect(
+ compile(
+ ``,
+ ),
+ ).toMatchSnapshot()
})
})