This repository was archived by the owner on Jul 19, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
packages/runtime-vapor/src Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import {
2323 type StaticProps ,
2424 getDynamicPropValue ,
2525} from './componentProps'
26+ import { warn } from './warning'
2627
2728export type ObjectEmitsOptions = Record <
2829 string ,
@@ -54,6 +55,33 @@ export function emit(
5455) {
5556 if ( instance . isUnmounted ) return
5657 // TODO
58+ if ( __DEV__ ) {
59+ const {
60+ emitsOptions,
61+ propsOptions : [ propsOptions ] ,
62+ } = instance
63+ if ( emitsOptions ) {
64+ if ( ! ( event in emitsOptions ) ) {
65+ if ( ! propsOptions || ! ( toHandlerKey ( event ) in propsOptions ) ) {
66+ warn (
67+ `Component emitted event "${ event } " but it is neither declared in ` +
68+ `the emits option nor as an "${ toHandlerKey ( event ) } " prop.` ,
69+ )
70+ }
71+ } else {
72+ const validator = emitsOptions [ event ]
73+ if ( isFunction ( validator ) ) {
74+ const isValid = validator ( ...rawArgs )
75+ if ( ! isValid ) {
76+ warn (
77+ `Invalid event arguments: event validation failed for event "${ event } ".` ,
78+ )
79+ }
80+ }
81+ }
82+ }
83+ }
84+
5785 const { rawProps, emitsOptions } = instance
5886 const hasDynamicProps = rawProps . some ( isFunction )
5987 const events : Record < string , ( ...args : any [ ] ) => any > = { }
You can’t perform that action at this time.
0 commit comments