mirror of https://github.com/vuejs/core.git
fix(runtime-dom): fix unnecessary warning when setting coerced dom property value
fix #6616
This commit is contained in:
parent
fc5bdb36ed
commit
b1817fe9ee
|
|
@ -240,6 +240,8 @@ describe('runtime-dom: props patching', () => {
|
|||
expect(el.size).toBe(100)
|
||||
patchProp(el, 'size', 100, null)
|
||||
expect(el.getAttribute('size')).toBe(null)
|
||||
expect('Failed setting prop "size" on <input>').not.toHaveBeenWarned()
|
||||
patchProp(el, 'size', null, 'foobar')
|
||||
expect('Failed setting prop "size" on <input>').toHaveBeenWarnedLast()
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,6 @@ export function patchDOMProp(
|
|||
needRemove = true
|
||||
} else if (type === 'number') {
|
||||
// e.g. <img :width="null">
|
||||
// the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error
|
||||
value = 0
|
||||
needRemove = true
|
||||
}
|
||||
|
|
@ -96,7 +95,8 @@ export function patchDOMProp(
|
|||
try {
|
||||
el[key] = value
|
||||
} catch (e: any) {
|
||||
if (__DEV__) {
|
||||
// do not warn if value is auto-coerced from nullish values
|
||||
if (__DEV__ && !needRemove) {
|
||||
warn(
|
||||
`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
|
||||
`value ${value} is invalid.`,
|
||||
|
|
|
|||
Loading…
Reference in New Issue