Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1a66474

Browse files
fix(compat): ensure false value on input retains value attribute (#13216)
close #13205
1 parent 013749e commit 1a66474

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export function compatCoerceAttr(
7979
}
8080
} else if (
8181
value === false &&
82+
!(el.tagName === 'INPUT' && key === 'value') &&
8283
!isSpecialBooleanAttr(key) &&
8384
compatUtils.isCompatEnabled(DeprecationTypes.ATTR_FALSE_VALUE, instance)
8485
) {

‎packages/vue-compat/__tests__/misc.spec.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,20 @@ test('ATTR_FALSE_VALUE', () => {
208208
).toHaveBeenWarned()
209209
})
210210

211+
test('ATTR_FALSE_VALUE with false on input value', () => {
212+
const vm = new Vue({
213+
template: `<input :value="false"/>`,
214+
}).$mount()
215+
expect(vm.$el).toBeInstanceOf(HTMLInputElement)
216+
expect(vm.$el.hasAttribute('value')).toBe(true)
217+
expect(vm.$el.getAttribute('value')).toBe('false')
218+
expect(
219+
(deprecationData[DeprecationTypes.ATTR_FALSE_VALUE].message as Function)(
220+
'value',
221+
),
222+
).not.toHaveBeenWarned()
223+
})
224+
211225
test("ATTR_FALSE_VALUE with false value shouldn't throw warning", () => {
212226
const vm = new Vue({
213227
template: `<div :id="false" :foo="false"/>`,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /