Skip to content

Commit b39e032

Browse files
authored
fix(runtime-core): prevent merging model listener when value is null or undefined (#14629)
fix https://github.com/vuejs/ecosystem-ci/actions/runs/23529115737/job/68488818862
1 parent 88ed045 commit b39e032

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

packages/runtime-core/__tests__/vnode.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,12 @@ describe('vnode', () => {
477477
expect(mergeProps({ onClick: null })).toMatchObject({
478478
onClick: null,
479479
})
480+
expect(
481+
mergeProps({ 'onUpdate:modelValue': undefined }),
482+
).not.toHaveProperty('onUpdate:modelValue')
483+
expect(mergeProps({ 'onUpdate:modelValue': null })).not.toHaveProperty(
484+
'onUpdate:modelValue',
485+
)
480486
})
481487

482488
test('default', () => {

packages/runtime-core/src/vnode.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
extend,
77
isArray,
88
isFunction,
9+
isModelListener,
910
isObject,
1011
isOn,
1112
isString,
@@ -891,7 +892,13 @@ export function mergeProps(...args: (Data & VNodeProps)[]): Data {
891892
ret[key] = existing
892893
? [].concat(existing as any, incoming as any)
893894
: incoming
894-
} else if (incoming == null && existing == null) {
895+
} else if (
896+
incoming == null &&
897+
existing == null &&
898+
// mergeProps({ 'onUpdate:modelValue': undefined }) should not retain
899+
// the model listener.
900+
!isModelListener(key)
901+
) {
895902
ret[key] = incoming
896903
}
897904
} else if (key !== '') {

0 commit comments

Comments
 (0)