From 0d057e207271bd82546eddd6376db4d7ff414a1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Csonka=20B=C3=A1lint?= Date: Thu, 13 May 2021 19:32:56 +0200 Subject: [PATCH] Make sure that throwing an exception in an observer does not leave the PropertiesChanged mixin in an invalid state --- lib/mixins/properties-changed.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/mixins/properties-changed.js b/lib/mixins/properties-changed.js index 9e481d6734..ee2d84224b 100644 --- a/lib/mixins/properties-changed.js +++ b/lib/mixins/properties-changed.js @@ -374,16 +374,19 @@ export const PropertiesChanged = dedupingMixin( * @override */ _flushProperties() { - this.__dataCounter++; - const props = this.__data; - const changedProps = this.__dataPending; - const old = this.__dataOld; - if (this._shouldPropertiesChange(props, changedProps, old)) { - this.__dataPending = null; - this.__dataOld = null; - this._propertiesChanged(props, changedProps, old); + try { + this.__dataCounter++; + const props = this.__data; + const changedProps = this.__dataPending; + const old = this.__dataOld; + if (this._shouldPropertiesChange(props, changedProps, old)) { + this.__dataPending = null; + this.__dataOld = null; + this._propertiesChanged(props, changedProps, old); + } + } finally { + this.__dataCounter--; } - this.__dataCounter--; } /**