fix(overlays): fix unhandled rejection

This commit is contained in:
Evita 2020-08-08 00:18:47 +03:00 committed by Joren Broekema
parent a768d62adc
commit 5a48e69bc7
2 changed files with 7 additions and 1 deletions

View file

@ -0,0 +1,5 @@
---
'@lion/overlays': patch
---
Add a guard for content wrapper containing the content node before appending to the renderTarget. This prevents unhandled rejection.

View file

@ -298,7 +298,8 @@ export class OverlayController {
this._renderTarget.appendChild(this.contentNode); this._renderTarget.appendChild(this.contentNode);
} else { } else {
const isInsideRenderTarget = this._renderTarget === this._contentWrapperNode.parentNode; const isInsideRenderTarget = this._renderTarget === this._contentWrapperNode.parentNode;
if (!isInsideRenderTarget) { const nodeContainsTarget = this._contentWrapperNode.contains(this._renderTarget);
if (!isInsideRenderTarget && !nodeContainsTarget) {
// contentWrapperNode becomes the direct (non projected) parent of contentNode // contentWrapperNode becomes the direct (non projected) parent of contentNode
this._renderTarget.appendChild(this._contentWrapperNode); this._renderTarget.appendChild(this._contentWrapperNode);
} }