Skip to content

Commit fbb9d85

Browse files
committed
fix(runtime-dom): avoid unnecessary prop patch for checkbox
1 parent 4b608a9 commit fbb9d85

File tree

1 file changed

+8
-1
lines changed
  • packages/runtime-dom/src/modules

1 file changed

+8
-1
lines changed

packages/runtime-dom/src/modules/props.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,14 @@ export function patchDOMProp(
3232
// compare against its attribute value instead.
3333
const oldValue =
3434
tag === 'OPTION' ? el.getAttribute('value') || '' : el.value
35-
const newValue = value == null ? '' : String(value)
35+
const newValue =
36+
value == null
37+
? // #11647: value should be set as empty string for null and undefined,
38+
// but <input type="checkbox"> should be set as 'no'.
39+
el.type === 'checkbox'
40+
? 'on'
41+
: ''
42+
: String(value)
3643
if (oldValue !== newValue || !('_value' in el)) {
3744
el.value = newValue
3845
}

0 commit comments

Comments
 (0)