|
1 | 1 | import { BackendContext } from '@vue-devtools/app-backend-api'
|
2 | 2 | import { getInstanceName, getUniqueComponentId } from './util'
|
3 |
| -import { camelize, StateEditor, SharedData } from '@vue-devtools/shared-utils' |
| 3 | +import { camelize, StateEditor, SharedData, kebabize } from '@vue-devtools/shared-utils' |
4 | 4 | import { ComponentInstance, CustomState, HookPayloads, Hooks, InspectedComponentData } from '@vue/devtools-api'
|
5 | 5 | import { returnError } from '../util'
|
6 | 6 |
|
@@ -371,20 +371,24 @@ function processRefs (instance) {
|
371 | 371 | function processEventListeners (instance) {
|
372 | 372 | const emitsDefinition = instance.type.emits
|
373 | 373 | const declaredEmits = Array.isArray(emitsDefinition) ? emitsDefinition : Object.keys(emitsDefinition ?? {})
|
| 374 | + const declaredEmitsMap = declaredEmits.reduce((emitsMap, key) => { |
| 375 | + emitsMap[kebabize(key)] = key |
| 376 | + return emitsMap |
| 377 | + }, {}) |
374 | 378 | const keys = Object.keys(instance.vnode.props ?? {})
|
375 | 379 | const result = []
|
376 | 380 | for (const key of keys) {
|
377 | 381 | const [prefix, ...eventNameParts] = key.split(/(?=[A-Z])/)
|
378 | 382 | if (prefix === 'on') {
|
379 | 383 | const eventName = eventNameParts.join('-').toLowerCase()
|
380 |
| - const isDeclared = declaredEmits.includes(eventName) |
| 384 | + const normalizedEventName = declaredEmitsMap[eventName] |
381 | 385 | result.push({
|
382 | 386 | type: 'event listeners',
|
383 |
| - key: eventName, |
| 387 | + key: normalizedEventName || eventName, |
384 | 388 | value: {
|
385 | 389 | _custom: {
|
386 |
| - display: isDeclared ? '✅ Declared' : '⚠️ Not declared', |
387 |
| - tooltip: !isDeclared ? `The event <code>${eventName}</code> is not declared in the <code>emits</code> option. It will leak into the component's attributes (<code>$attrs</code>).` : null, |
| 390 | + display: normalizedEventName ? '✅ Declared' : '⚠️ Not declared', |
| 391 | + tooltip: !normalizedEventName ? `The event <code>${eventName}</code> is not declared in the <code>emits</code> option. It will leak into the component's attributes (<code>$attrs</code>).` : null, |
388 | 392 | },
|
389 | 393 | },
|
390 | 394 | })
|
|
0 commit comments