fix(runtime-dom): capture errors when setting value for IDL (#3578)
fix #3576
This commit is contained in:
parent
18911abb91
commit
3756270272
@ -170,4 +170,12 @@ describe('runtime-dom: props patching', () => {
|
|||||||
// see https://github.com/vuejs/vue-next/issues/2766
|
// see https://github.com/vuejs/vue-next/issues/2766
|
||||||
patchProp(el, 'type', 'text', null)
|
patchProp(el, 'type', 'text', null)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
test('input with size', () => {
|
||||||
|
const el = document.createElement('input')
|
||||||
|
patchProp(el, 'size', null, 100)
|
||||||
|
expect(el.size).toBe(100)
|
||||||
|
patchProp(el, 'size', 100, null)
|
||||||
|
expect(el.getAttribute('size')).toBe(null)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
@ -52,7 +52,10 @@ export function patchDOMProp(
|
|||||||
return
|
return
|
||||||
} else if (type === 'number') {
|
} else if (type === 'number') {
|
||||||
// e.g. <img :width="null">
|
// e.g. <img :width="null">
|
||||||
|
// the value of some IDL attr must be greater than 0, e.g. input.size = 0 -> error
|
||||||
|
try {
|
||||||
el[key] = 0
|
el[key] = 0
|
||||||
|
} catch {}
|
||||||
el.removeAttribute(key)
|
el.removeAttribute(key)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user