From 4e439bd5e8752f4c03d3001423c93c8bb6a160ec Mon Sep 17 00:00:00 2001 From: Vladislav Tasev Date: Wed, 22 May 2019 09:43:11 +0300 Subject: [PATCH 1/2] fix broken child property observation --- packages/base/src/UI5Element.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/base/src/UI5Element.js b/packages/base/src/UI5Element.js index 06347886c240..db343d173c2d 100644 --- a/packages/base/src/UI5Element.js +++ b/packages/base/src/UI5Element.js @@ -371,7 +371,7 @@ class UI5Element extends HTMLElement { return; } - const slotName = this.constructor._getSlotName(this); + const slotName = this.parentNode.constructor._getSlotName(this); const propsMetadata = this.parentNode._monitoredChildProps.get(slotName); if (!propsMetadata) { From 1354ca2433fc13b65c370341f159091874818fc1 Mon Sep 17 00:00:00 2001 From: Vladislav Tasev Date: Wed, 22 May 2019 10:15:43 +0300 Subject: [PATCH 2/2] refactor confusing names --- packages/base/src/UI5Element.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/base/src/UI5Element.js b/packages/base/src/UI5Element.js index db343d173c2d..ea179fe7dc10 100644 --- a/packages/base/src/UI5Element.js +++ b/packages/base/src/UI5Element.js @@ -359,20 +359,22 @@ class UI5Element extends HTMLElement { this._monitoredChildProps.set(slotName, { observedProps, notObservedProps }); } - child.addEventListener("_propertyChange", this._onChildPropertyUpdated); + child.addEventListener("_propertyChange", this._invalidateParentOfPropertyUpdate); } _detachChildPropertyUpdated(child) { - child.removeEventListener("_propertyChange", this._onChildPropertyUpdated); + child.removeEventListener("_propertyChange", this._invalidateParentOfPropertyUpdate); } - _onChildPropertyUpdated(prop) { - if (!this.parentNode) { + _invalidateParentOfPropertyUpdate(prop) { + // The web component to be invalidated + const parentNode = this.parentNode; + if (!parentNode) { return; } - const slotName = this.parentNode.constructor._getSlotName(this); - const propsMetadata = this.parentNode._monitoredChildProps.get(slotName); + const slotName = parentNode.constructor._getSlotName(this); + const propsMetadata = parentNode._monitoredChildProps.get(slotName); if (!propsMetadata) { return; @@ -380,7 +382,7 @@ class UI5Element extends HTMLElement { const { observedProps, notObservedProps } = propsMetadata; if (observedProps.includes(prop.detail.name) && !notObservedProps.includes(prop.detail.name)) { - this.parentNode._invalidate("_parent_", this); + parentNode._invalidate("_parent_", this); } }