Skip to content

Commit

Permalink
fix(runtime-core): ensure mergeProps skips undefined event handlers (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
LinusBorg committed Jan 21, 2022
1 parent 2f91872 commit c35ec47
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/runtime-core/__tests__/vnode.spec.ts
Expand Up @@ -446,6 +446,10 @@ describe('vnode', () => {
onClick: [clickHandler1, clickHandler2],
onFocus: focusHandler2
})
let props3: Data = { onClick: undefined }
expect(mergeProps(props1, props3)).toMatchObject({
onClick: clickHandler1
})
})

test('default', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/runtime-core/src/vnode.ts
Expand Up @@ -798,6 +798,7 @@ export function mergeProps(...args: (Data & VNodeProps)[]) {
const existing = ret[key]
const incoming = toMerge[key]
if (
incoming &&
existing !== incoming &&
!(isArray(existing) && existing.includes(incoming))
) {
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-dom/src/modules/events.ts
Expand Up @@ -141,7 +141,7 @@ function patchStopImmediatePropagation(
originalStop.call(e)
;(e as any)._stopped = true
}
return value.map(fn => (e: Event) => !(e as any)._stopped && fn(e))
return value.map(fn => (e: Event) => !(e as any)._stopped && fn && fn(e))
} else {
return value
}
Expand Down

0 comments on commit c35ec47

Please sign in to comment.