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

feat(framework): implement invalidateParent #1964

Merged
merged 4 commits into from
Jul 20, 2020
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion docs/dev/Metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Setting | Type | Default | Description
`individualSlots` | `Boolean` | false | If set to `true`, each child will have its own slot, allowing you to arrange/wrap the children arbitrarily.
`propertyName` | `String` | N/A | Allows to set the name of the property on the Web Component, where the children belonging to this slot will be stored.
`listenFor` | `Object` | N/A | **Experimental, do not use.** If set, whenever the children, belonging to this slot have their properties changed, the Web Component will be invalidated.

`invalidateParent` | `Boolean` | false | **Experimental, do not use.** Defines whether every invalidation of a UI5 Web Component in this slot should trigger an invalidation of the parent UI5 Web Component.
The `type` setting is required.

Notes:
Expand Down
13 changes: 13 additions & 0 deletions packages/base/src/UI5Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class UI5Element extends HTMLElement {

this._monitoredChildProps = new Map();
this._firePropertyChange = false;
this._shouldInvalidateParent = false;
}

/**
Expand Down Expand Up @@ -267,6 +268,10 @@ class UI5Element extends HTMLElement {
this._attachChildPropertyUpdated(child, slotData.listenFor);
}

if (child.isUI5Element && slotData.invalidateParent) {
child._shouldInvalidateParent = true;
}

if (isSlot(child)) {
this._attachSlotChange(child);
}
Expand Down Expand Up @@ -307,6 +312,10 @@ class UI5Element extends HTMLElement {
this._detachChildPropertyUpdated(child);
}

if (child.isUI5Element && slotData.invalidateParent) {
fifoosid marked this conversation as resolved.
Show resolved Hide resolved
child._shouldInvalidateParent = false;
}

if (isSlot(child)) {
this._detachSlotChange(child);
}
Expand Down Expand Up @@ -496,6 +505,10 @@ class UI5Element extends HTMLElement {
this._upToDate = false;
// console.log("INVAL", this, ...arguments);
RenderScheduler.renderDeferred(this);

if (this._shouldInvalidateParent) {
this.parentNode._invalidate();
}
}
}

Expand Down