Skip to content

Commit

Permalink
fix(runtime-dom): also set attribute for form element state
Browse files Browse the repository at this point in the history
close #6007
close #6012
  • Loading branch information
yyx990803 committed May 31, 2024
1 parent a52a02f commit 537a571
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/runtime-dom/src/modules/attrs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export function patchAttr(
value: any,
isSVG: boolean,
instance?: ComponentInternalInstance | null,
isBoolean = isSpecialBooleanAttr(key),
) {
if (isSVG && key.startsWith('xlink:')) {
if (value == null) {
Expand All @@ -32,7 +33,6 @@ export function patchAttr(

// note we are only checking boolean attributes that don't have a
// corresponding dom prop of the same name here.
const isBoolean = isSpecialBooleanAttr(key)
if (value == null || (isBoolean && !includeBooleanAttr(value))) {
el.removeAttribute(key)
} else {
Expand Down
5 changes: 5 additions & 0 deletions packages/runtime-dom/src/patchProp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export const patchProp: DOMRendererOptions['patchProp'] = (
parentSuspense,
unmountChildren,
)
// #6007 also set form state as attributes so they work with
// <input type="reset"> or libs / extensions that expect attributes
if (key === 'value' || key === 'checked' || key === 'selected') {
patchAttr(el, key, nextValue, isSVG, parentComponent, key !== 'value')
}
} else {
// special case for <input v-model type="checkbox"> with
// :true-value & :false-value
Expand Down

0 comments on commit 537a571

Please sign in to comment.