Skip to content

Commit

Permalink
fix: broken child property observation (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
vladitasev authored May 22, 2019
1 parent 115900b commit b3e3b3f
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/base/src/UI5Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,28 +359,30 @@ 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.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;
}
const { observedProps, notObservedProps } = propsMetadata;

if (observedProps.includes(prop.detail.name) && !notObservedProps.includes(prop.detail.name)) {
this.parentNode._invalidate("_parent_", this);
parentNode._invalidate("_parent_", this);
}
}

Expand Down

0 comments on commit b3e3b3f

Please sign in to comment.