{"record":{"id":"abe2f3c6a3809f1d","repo":"Meituan-Dianping/mpvue","slug":"invalid-handler-for-event-event-name-got-s","errorCode":null,"errorMessage":"Invalid handler for event \"${event.name}\": got ${String(cur)}","messagePattern":"Invalid handler for event \"(.+?)\": got (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/core/vdom/helpers/update-listeners.js","lineNumber":56,"sourceCode":"  }\n  invoker.fns = fns\n  return invoker\n}\n\nexport function updateListeners (\n  on: Object,\n  oldOn: Object,\n  add: Function,\n  remove: Function,\n  vm: Component\n) {\n  let name, cur, old, event\n  for (name in on) {\n    cur = on[name]\n    old = oldOn[name]\n    event = normalizeEvent(name)\n    if (isUndef(cur)) {\n      process.env.NODE_ENV !== 'production' && warn(\n        `Invalid handler for event \"${event.name}\": got ` + String(cur),\n        vm\n      )\n    } else if (isUndef(old)) {\n      if (isUndef(cur.fns)) {\n        cur = on[name] = createFnInvoker(cur)\n      }\n      add(event.name, cur, event.once, event.capture, event.passive)\n    } else if (cur !== old) {\n      old.fns = cur\n      on[name] = old\n    }\n  }\n  for (name in oldOn) {\n    if (isUndef(on[name])) {\n      event = normalizeEvent(name)\n      remove(event.name, oldOn[name], event.capture)\n    }","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/Meituan-Dianping/mpvue/blob/6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b/src/core/vdom/helpers/update-listeners.js#L38-L74","documentation":"During vnode update, an entry in the `on` listeners object is `undefined`/`null`, meaning the component asked to listen to an event but supplied no handler function. Vue warns and skips attaching the listener.","triggerScenarios":"`h(MyComp, { on: { click: undefined } })`; spreading an object of handlers where a key exists but its value is undefined; building `on` from reactive data where a handler is conditionally absent.","commonSituations":"Dynamically assembling listener maps in render functions; destructuring props that lack a handler; TypeScript-less code where a handler name is misspelled and resolves to undefined.","solutions":["Remove the listener key entirely when there is no handler, instead of setting it to undefined","Guard with a fallback: `on: { click: this.onClick || (() => {}) }`","Filter out falsy handlers before passing: `on: Object.fromEntries(Object.entries(handlers).filter(([, fn]) => fn))`","Fix misspelled handler references"],"exampleFix":"// before\nh('input', { on: { input: props.onInput } }) // onInput may be undefined\n// after\nconst handlers = {}\nif (props.onInput) handlers.input = props.onInput\nh('input', { on: handlers })","handlingStrategy":"type-guard","validationCode":"function validOn (on) {\n  const out = {}\n  for (const k in on) if (typeof on[k] === 'function') out[k] = on[k]\n  return out\n}\n// usage: h(Comp, { on: validOn(handlers) })","typeGuard":"function isHandler (fn) { return typeof fn === 'function' }","tryCatchPattern":null,"preventionTips":["Never set listener keys to undefined; omit them","Build listener maps by explicit assignment, not blind spread","Type-check handler props (Function type in prop definitions)","Guard optional handlers: handler && handler(...)"],"tags":["vdom","event-handler","render-function"],"backgroundTag":"invalid-event-handler","analyzedSha":"6c5d78ee04f58c6d782c456dfcf0fe63c0b7f89b","analyzedAt":"2026-09-02T05:17:40.946Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T11:17:12.671Z"}