]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
feat(devtools): catch events
authorGuillaume Chau <guillaume.b.chau@gmail.com>
Sun, 23 Aug 2020 23:31:32 +0000 (01:31 +0200)
committerGuillaume Chau <guillaume.b.chau@gmail.com>
Sun, 23 Aug 2020 23:33:12 +0000 (01:33 +0200)
packages/runtime-core/src/componentEmits.ts
packages/runtime-core/src/devtools.ts

index d75bc28ea12eecb4a8fe8e95e2cca76d648de025..33ca7f69458e09b29e0bff71622f8fcf9b4f661f 100644 (file)
@@ -13,6 +13,7 @@ import { callWithAsyncErrorHandling, ErrorCodes } from './errorHandling'
 import { warn } from './warning'
 import { normalizePropsOptions } from './componentProps'
 import { UnionToIntersection } from './helpers/typeUtils'
+import { devtoolsComponentEmit } from './devtools'
 
 export type ObjectEmitsOptions = Record<
   string,
@@ -67,6 +68,10 @@ export function emit(
     }
   }
 
+  if (__DEV__ || __FEATURE_PROD_DEVTOOLS__) {
+    devtoolsComponentEmit(instance, event, args)
+  }
+
   let handlerName = `on${capitalize(event)}`
   let handler = props[handlerName]
   // for v-model update:xxx events, also trigger kebab-case equivalent
index a83048f4be26f9e5dc99562e5c9eac5c0e11be7b..98ba3cd597cb70a612284277d21630b5309cde5c 100644 (file)
@@ -14,7 +14,8 @@ const enum DevtoolsHooks {
   APP_UNMOUNT = 'app:unmount',
   COMPONENT_UPDATED = 'component:updated',
   COMPONENT_ADDED = 'component:added',
-  COMPONENT_REMOVED = 'component:removed'
+  COMPONENT_REMOVED = 'component:removed',
+  COMPONENT_EMIT = 'component:emit'
 }
 
 interface DevtoolsHook {
@@ -70,3 +71,18 @@ function createDevtoolsComponentHook(hook: DevtoolsHooks) {
     )
   }
 }
+
+export function devtoolsComponentEmit(
+  component: ComponentInternalInstance,
+  event: string,
+  params: any[]
+) {
+  if (!devtools) return
+  devtools.emit(
+    DevtoolsHooks.COMPONENT_EMIT,
+    component.appContext.app,
+    component.uid,
+    event,
+    params
+  )
+}