Skip to content

Commit 8a80a23

Browse files
committed
fix: avoid errors thrown during dom props update
breaking the entire app fix #9459
1 parent cd3d202 commit 8a80a23

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/platforms/web/runtime/modules/dom-props.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function updateDOMProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
3838
}
3939
}
4040

41-
if (key === 'value') {
41+
if (key === 'value' && elm.tagName !== 'PROGRESS') {
4242
// store value as _value as well since
4343
// non-string values will be stringified
4444
elm._value = cur
@@ -65,7 +65,11 @@ function updateDOMProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
6565
// This #4521 by skipping the unnecesarry `checked` update.
6666
cur !== oldProps[key]
6767
) {
68-
elm[key] = cur
68+
// some property updates can throw
69+
// e.g. `value` on <progress> w/ non-finite value
70+
try {
71+
elm[key] = cur
72+
} catch (e) {}
6973
}
7074
}
7175
}

test/unit/modules/vdom/patch/edge-cases.spec.js

+22
Original file line numberDiff line numberDiff line change
@@ -410,4 +410,26 @@ describe('vdom patch: edge cases', () => {
410410
expect(vm.$el.textContent).toBe('FooBar')
411411
expect(inlineHookSpy.calls.count()).toBe(2)
412412
})
413+
414+
// #9549
415+
it('DOM props set throwing should not break app', done => {
416+
const vm = new Vue({
417+
data: {
418+
n: Infinity
419+
},
420+
template: `
421+
<div>
422+
<progress :value="n"/>
423+
{{ n }}
424+
</div>
425+
`
426+
}).$mount()
427+
428+
expect(vm.$el.textContent).toMatch('Infinity')
429+
vm.n = 1
430+
waitForUpdate(() => {
431+
expect(vm.$el.textContent).toMatch('1')
432+
expect(vm.$el.textContent).not.toMatch('Infinity')
433+
}).then(done)
434+
})
413435
})

0 commit comments

Comments
 (0)