Subscribe on changes!

mergeProps does not merge correctly event listeners

avatar
Jan 20th 2022

Version

3.2.27

Reproduction link

sfc.vuejs.org

Steps to reproduce

  • Open the console to see what's going on
  • Type anything into the input field

What is expected?

Event listeners to be merged correctly

What is actually happening?

Vue throws TypeError: fn is not a function. This happens because, when we try to merge two objects with the same event listeners but one of the objects contains an event with an undefined value, then the result will be an array with an undefined value.

const result = mergeProps({ onKeydown() {} }, { onKeydown: undefined })

// result ---> { onKeydown: [fn, undefined] }