From 557de4cd0679ac2b58efbcd3d89d4c410a9acf34 Mon Sep 17 00:00:00 2001 From: Evan You Date: Thu, 21 Feb 2019 13:54:28 -0500 Subject: [PATCH] fix: avoid errors thrown during dom props update breaking the entire app fix #9459 --- .../web/runtime/modules/dom-props.js | 8 +++++-- .../modules/vdom/patch/edge-cases.spec.js | 22 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/platforms/web/runtime/modules/dom-props.js b/src/platforms/web/runtime/modules/dom-props.js index 43dc2f1658a..3e322462675 100644 --- a/src/platforms/web/runtime/modules/dom-props.js +++ b/src/platforms/web/runtime/modules/dom-props.js @@ -38,7 +38,7 @@ function updateDOMProps (oldVnode: VNodeWithData, vnode: VNodeWithData) { } } - if (key === 'value') { + if (key === 'value' && elm.tagName !== 'PROGRESS') { // store value as _value as well since // non-string values will be stringified elm._value = cur @@ -65,7 +65,11 @@ function updateDOMProps (oldVnode: VNodeWithData, vnode: VNodeWithData) { // This #4521 by skipping the unnecesarry `checked` update. cur !== oldProps[key] ) { - elm[key] = cur + // some property updates can throw + // e.g. `value` on w/ non-finite value + try { + elm[key] = cur + } catch (e) {} } } } diff --git a/test/unit/modules/vdom/patch/edge-cases.spec.js b/test/unit/modules/vdom/patch/edge-cases.spec.js index a1c492d4b3e..a7f7ba38932 100644 --- a/test/unit/modules/vdom/patch/edge-cases.spec.js +++ b/test/unit/modules/vdom/patch/edge-cases.spec.js @@ -410,4 +410,26 @@ describe('vdom patch: edge cases', () => { expect(vm.$el.textContent).toBe('FooBar') expect(inlineHookSpy.calls.count()).toBe(2) }) + + // #9549 + it('DOM props set throwing should not break app', done => { + const vm = new Vue({ + data: { + n: Infinity + }, + template: ` +
+ + {{ n }} +
+ ` + }).$mount() + + expect(vm.$el.textContent).toMatch('Infinity') + vm.n = 1 + waitForUpdate(() => { + expect(vm.$el.textContent).toMatch('1') + expect(vm.$el.textContent).not.toMatch('Infinity') + }).then(done) + }) })