Skip to content

Commit 537a571

Browse files
committedMay 31, 2024··
fix(runtime-dom): also set attribute for form element state
close #6007 close #6012
1 parent a52a02f commit 537a571

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed
 

‎packages/runtime-dom/src/modules/attrs.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export function patchAttr(
1818
value: any,
1919
isSVG: boolean,
2020
instance?: ComponentInternalInstance | null,
21+
isBoolean = isSpecialBooleanAttr(key),
2122
) {
2223
if (isSVG && key.startsWith('xlink:')) {
2324
if (value == null) {
@@ -32,7 +33,6 @@ export function patchAttr(
3233

3334
// note we are only checking boolean attributes that don't have a
3435
// corresponding dom prop of the same name here.
35-
const isBoolean = isSpecialBooleanAttr(key)
3636
if (value == null || (isBoolean && !includeBooleanAttr(value))) {
3737
el.removeAttribute(key)
3838
} else {

‎packages/runtime-dom/src/patchProp.ts

+5
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ export const patchProp: DOMRendererOptions['patchProp'] = (
5252
parentSuspense,
5353
unmountChildren,
5454
)
55+
// #6007 also set form state as attributes so they work with
56+
// <input type="reset"> or libs / extensions that expect attributes
57+
if (key === 'value' || key === 'checked' || key === 'selected') {
58+
patchAttr(el, key, nextValue, isSVG, parentComponent, key !== 'value')
59+
}
5560
} else {
5661
// special case for <input v-model type="checkbox"> with
5762
// :true-value & :false-value

0 commit comments

Comments
 (0)
Please sign in to comment.