]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
chore: improve event value validation message
authorEvan You <yyx990803@gmail.com>
Mon, 15 Apr 2024 15:39:59 +0000 (23:39 +0800)
committerEvan You <yyx990803@gmail.com>
Mon, 15 Apr 2024 15:39:59 +0000 (23:39 +0800)
packages/runtime-dom/__tests__/patchEvents.spec.ts
packages/runtime-dom/src/modules/events.ts

index b7a5af0ed0ed8ef2a95674dc6d6c5bfad853f9be..f70bf327affa075a0d47c4e25eebcdc33413cc50 100644 (file)
@@ -198,9 +198,8 @@ describe(`runtime-dom: events patching`, () => {
     patchProp(el, 'onClick', null, 'test')
     el.dispatchEvent(new Event('click'))
     expect(
-      '[Vue warn]: Wrong type passed to the event invoker, ' +
-        'did you maybe forget @ or : in front of your prop?' +
-        '\nReceived onClick="test"',
+      `Wrong type passed as event handler to onClick - did you forget @ or : ` +
+        `in front of your prop?\nExpected function or array of functions, received type string.`,
     ).toHaveBeenWarned()
   })
 })
index 09e4a22a84cd2a3d982047350936396d30d504d1..fd049a88f0db3075154d6ab459d95f8f8287f506 100644 (file)
@@ -1,4 +1,4 @@
-import { NOOP, hyphenate, isArray, isFunction, isString } from '@vue/shared'
+import { NOOP, hyphenate, isArray, isFunction } from '@vue/shared'
 import {
   type ComponentInternalInstance,
   ErrorCodes,
@@ -129,9 +129,8 @@ function sanitizeEventValue(value: unknown, propName: string): EventValue {
     return value as EventValue
   }
   warn(
-    `Wrong type passed to the event invoker, did you maybe forget @ or : ` +
-      `in front of your prop?\nReceived ` +
-      `${propName}=${isString(value) ? JSON.stringify(value) : `[${typeof value}]`}`,
+    `Wrong type passed as event handler to ${propName} - did you forget @ or : ` +
+      `in front of your prop?\nExpected function or array of functions, received type ${typeof value}.`,
   )
   return NOOP
 }