Skip to content

Commit

Permalink
feat(framework): implement invalidateParent (#1964)
Browse files Browse the repository at this point in the history
  • Loading branch information
fifoosid committed Jul 20, 2020
1 parent 45cdcc2 commit 104abcc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
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
10 changes: 10 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 @@ -305,6 +310,7 @@ class UI5Element extends HTMLElement {
children.forEach(child => {
if (child && child.isUI5Element) {
this._detachChildPropertyUpdated(child);
child._shouldInvalidateParent = false;
}

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

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

Expand Down

0 comments on commit 104abcc

Please sign in to comment.