Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix broken child property observation #423

Merged
merged 2 commits into from
May 22, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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