fix(runtime-core): ensure mergeProps skips undefined event handlers (#5299)
fix #5296
This commit is contained in:
parent
2f91872e7b
commit
c35ec47d73
@ -446,6 +446,10 @@ describe('vnode', () => {
|
|||||||
onClick: [clickHandler1, clickHandler2],
|
onClick: [clickHandler1, clickHandler2],
|
||||||
onFocus: focusHandler2
|
onFocus: focusHandler2
|
||||||
})
|
})
|
||||||
|
let props3: Data = { onClick: undefined }
|
||||||
|
expect(mergeProps(props1, props3)).toMatchObject({
|
||||||
|
onClick: clickHandler1
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
test('default', () => {
|
test('default', () => {
|
||||||
|
@ -798,6 +798,7 @@ export function mergeProps(...args: (Data & VNodeProps)[]) {
|
|||||||
const existing = ret[key]
|
const existing = ret[key]
|
||||||
const incoming = toMerge[key]
|
const incoming = toMerge[key]
|
||||||
if (
|
if (
|
||||||
|
incoming &&
|
||||||
existing !== incoming &&
|
existing !== incoming &&
|
||||||
!(isArray(existing) && existing.includes(incoming))
|
!(isArray(existing) && existing.includes(incoming))
|
||||||
) {
|
) {
|
||||||
|
@ -141,7 +141,7 @@ function patchStopImmediatePropagation(
|
|||||||
originalStop.call(e)
|
originalStop.call(e)
|
||||||
;(e as any)._stopped = true
|
;(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 {
|
} else {
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user