Skip to content

Commit

Permalink
fix: Fix the unmatch the case problem that results the emitted event …
Browse files Browse the repository at this point in the history
…undeclared
  • Loading branch information
Azurewarth0920 committed Apr 13, 2023
1 parent 1b1d1d0 commit 793b3d2
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/app-backend-vue3/src/components/data.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BackendContext } from '@vue-devtools/app-backend-api'
import { getInstanceName, getUniqueComponentId } from './util'
import { camelize, StateEditor, SharedData } from '@vue-devtools/shared-utils'
import { camelize, StateEditor, SharedData, kebabize } from '@vue-devtools/shared-utils'
import { ComponentInstance, CustomState, HookPayloads, Hooks, InspectedComponentData } from '@vue/devtools-api'
import { returnError } from '../util'

Expand Down Expand Up @@ -371,13 +371,14 @@ function processRefs (instance) {
function processEventListeners (instance) {
const emitsDefinition = instance.type.emits
const declaredEmits = Array.isArray(emitsDefinition) ? emitsDefinition : Object.keys(emitsDefinition ?? {})
const normalizedDeclaredEmits = declaredEmits.map(key => kebabize(key))
const keys = Object.keys(instance.vnode.props ?? {})
const result = []
for (const key of keys) {
const [prefix, ...eventNameParts] = key.split(/(?=[A-Z])/)
if (prefix === 'on') {
const eventName = eventNameParts.join('-').toLowerCase()
const isDeclared = declaredEmits.includes(eventName)
const isDeclared = normalizedDeclaredEmits.includes(eventName)
result.push({
type: 'event listeners',
key: eventName,
Expand Down

0 comments on commit 793b3d2

Please sign in to comment.