Merge pull request #865 from Evittta/fix/overlays-unhandled-rejection

fix: [overlay] fix unhandled rejection
This commit is contained in:
Joren Broekema 2020-08-10 10:54:16 +02:00 committed by GitHub
commit fc51027adb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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);
} }