fix(compat): ensure false value on input retains value attribute (#13216)
close #13205
This commit is contained in:
parent
013749e75e
commit
1a664749d4
|
@ -79,6 +79,7 @@ export function compatCoerceAttr(
|
|||
}
|
||||
} else if (
|
||||
value === false &&
|
||||
!(el.tagName === 'INPUT' && key === 'value') &&
|
||||
!isSpecialBooleanAttr(key) &&
|
||||
compatUtils.isCompatEnabled(DeprecationTypes.ATTR_FALSE_VALUE, instance)
|
||||
) {
|
||||
|
|
|
@ -208,6 +208,20 @@ test('ATTR_FALSE_VALUE', () => {
|
|||
).toHaveBeenWarned()
|
||||
})
|
||||
|
||||
test('ATTR_FALSE_VALUE with false on input value', () => {
|
||||
const vm = new Vue({
|
||||
template: `<input :value="false"/>`,
|
||||
}).$mount()
|
||||
expect(vm.$el).toBeInstanceOf(HTMLInputElement)
|
||||
expect(vm.$el.hasAttribute('value')).toBe(true)
|
||||
expect(vm.$el.getAttribute('value')).toBe('false')
|
||||
expect(
|
||||
(deprecationData[DeprecationTypes.ATTR_FALSE_VALUE].message as Function)(
|
||||
'value',
|
||||
),
|
||||
).not.toHaveBeenWarned()
|
||||
})
|
||||
|
||||
test("ATTR_FALSE_VALUE with false value shouldn't throw warning", () => {
|
||||
const vm = new Vue({
|
||||
template: `<div :id="false" :foo="false"/>`,
|
||||
|
|
Loading…
Reference in New Issue