Subscribe on changes!

Mixins trigger an emitted event warning

avatar
Nov 20th 2020

Version

3.0.2

Reproduction link

https://jsfiddle.net/skirtle/yofbtL0h/

Steps to reproduce

  1. Click the button. Note the warning.
  2. Remove the line app.mixin({}) and re-run the Fiddle.
  3. Clicking the button no longer triggers a warning.

What is expected?

No warning, even with the mixin.

What is actually happening?

[Vue warn]: Component emitted event "update:modelValue" but it is neither
declared in the emits option nor as an "onUpdate:modelValue" prop.

The warning is only supposed to be shown when the emits option is specified. Nothing in this example specifies an emits option, so it shouldn't be shown.

The same problem occurs when using the mixins or extends options.

I believe it's caused by an inconsistency in normalizeEmitsOptions:

https://github.com/vuejs/vue-next/blob/2707cbf36e39ff2a54d84fc82ea62d2dc3af5b05/packages/runtime-core/src/componentEmits.ts#L152

Without the mixin it returns null. With the mixin it returns an empty object, which is enough to trigger the warning.

Originally observed in https://github.com/vuejs/docs-next/issues/702