diff --git a/packages/runtime-core/__tests__/componentEmits.spec.ts b/packages/runtime-core/__tests__/componentEmits.spec.ts index 86307275bf8..654ba17c4b0 100644 --- a/packages/runtime-core/__tests__/componentEmits.spec.ts +++ b/packages/runtime-core/__tests__/componentEmits.spec.ts @@ -415,6 +415,7 @@ describe('component: emit', () => { 'test-event': null, fooBar: null, FooBaz: null, + once: null, } expect(isEmitListener(options, 'onClick')).toBe(true) expect(isEmitListener(options, 'onclick')).toBe(false) @@ -428,6 +429,9 @@ describe('component: emit', () => { expect(isEmitListener(options, 'onFooBar')).toBe(true) // PascalCase option expect(isEmitListener(options, 'onFooBaz')).toBe(true) + // #8342 + expect(isEmitListener(options, 'onOnceOnce')).toBe(true) + expect(isEmitListener(options, 'onOnce')).toBe(true) }) test('does not emit after unmount', async () => { diff --git a/packages/runtime-core/src/componentEmits.ts b/packages/runtime-core/src/componentEmits.ts index 3c0a111aa3e..c8ef5c0883a 100644 --- a/packages/runtime-core/src/componentEmits.ts +++ b/packages/runtime-core/src/componentEmits.ts @@ -269,8 +269,11 @@ export function isEmitListener( if (__COMPAT__ && key.startsWith(compatModelEventPrefix)) { return true } - - key = key.slice(2).replace(/Once$/, '') + key = key.slice(2) + // #8342 + // e.g. emits: { once: null } -> onOnce态ononce + // Does not require regular expression processing + key = key.toLowerCase() === 'once' ? key : key.replace(/Once$/, '') return ( hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) ||