From 51b48300c726c7185822b3b3ab7f497168e74d91 Mon Sep 17 00:00:00 2001 From: Spring Raindrop Date: Sat, 9 Oct 2021 23:12:57 +0000 Subject: [PATCH 1/2] chore(warn): fix camelCase event tip Correctly state which event was emitted and which there is a listener for, as they were conflated before. --- src/core/instance/events.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/instance/events.js b/src/core/instance/events.js index 4d5bb552850..3b4be64a0e7 100644 --- a/src/core/instance/events.js +++ b/src/core/instance/events.js @@ -121,8 +121,9 @@ export function eventsMixin (Vue: Class) { const lowerCaseEvent = event.toLowerCase() if (lowerCaseEvent !== event && vm._events[lowerCaseEvent]) { tip( - `Event "${lowerCaseEvent}" is emitted in component ` + - `${formatComponentName(vm)} but the handler is registered for "${event}". ` + + `Event "${event}" is emitted in component ` + + `${formatComponentName(vm)} but the handler is registered for ` + + `"${lowerCaseEvent}". ` + `Note that HTML attributes are case-insensitive and you cannot use ` + `v-on to listen to camelCase events when using in-DOM templates. ` + `You should probably use "${hyphenate(event)}" instead of "${event}".` From 3687669a08a94bdf2c4741070e3024ff706af7e6 Mon Sep 17 00:00:00 2001 From: Spring Raindrop Date: Sun, 10 Oct 2021 13:39:31 +0000 Subject: [PATCH 2/2] test(warn): extend camelCase prop and event tests Test for correct order of what is expected and what was passed. --- test/unit/features/component/component.spec.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/unit/features/component/component.spec.js b/test/unit/features/component/component.spec.js index 697a9dddbe7..23eb5e805a3 100644 --- a/test/unit/features/component/component.spec.js +++ b/test/unit/features/component/component.spec.js @@ -289,6 +289,8 @@ describe('Component', () => { } } }).$mount() + expect('"somecollection" is passed').toHaveBeenTipped() + expect('declared prop name is "someCollection"').toHaveBeenTipped() expect( 'You should probably use "some-collection" instead of "someCollection".' ).toHaveBeenTipped() @@ -306,6 +308,8 @@ describe('Component', () => { } } }).$mount() + expect('"fooBar" is emitted').toHaveBeenTipped() + expect('handler is registered for "foobar"').toHaveBeenTipped() expect( 'You should probably use "foo-bar" instead of "fooBar".' ).toHaveBeenTipped()