From f2625bba920607267930fb8496a9e6d2ad8a87cc Mon Sep 17 00:00:00 2001 From: Thomas Pink Date: Thu, 27 Aug 2020 15:34:41 +0200 Subject: [PATCH] fix(container-breakpoint-observer): Added logging information where the placeholder container is applied so tracking this issue if it is occurring again is easier. Solves #1526 --- .../src/container-breakpoint-observer.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/libs/barista-components/container-breakpoint-observer/src/container-breakpoint-observer.ts b/libs/barista-components/container-breakpoint-observer/src/container-breakpoint-observer.ts index 23fe0873e2..22516ec1cd 100644 --- a/libs/barista-components/container-breakpoint-observer/src/container-breakpoint-observer.ts +++ b/libs/barista-components/container-breakpoint-observer/src/container-breakpoint-observer.ts @@ -1,3 +1,4 @@ +occurring; /** * @license * Copyright 2020 Dynatrace LLC @@ -36,6 +37,9 @@ import { convertQuery, isElementQuery, } from './query'; +import { DtLogger, DtLoggerFactory } from '@dynatrace/barista-components/core'; + +const LOG: DtLogger = DtLoggerFactory.create('DtContainerBreakpointObserver'); /** * @internal @@ -273,7 +277,20 @@ export class DtContainerBreakpointObserver implements OnDestroy { placeholder.style.height = elementQuery.feature === 'height' ? elementQuery.value : '1px'; placeholder.className = PLACEHOLDER_ELEMENT_CLASS; - this._placeholderContainer.nativeElement.append(placeholder); + try { + this._placeholderContainer.nativeElement.append(placeholder); + } catch (ex) { + // This try/catch is there to track down the js-error described the issue #1526. + // TODO: Remove if no errors appear in the future or if the root cause has been found. + const hasAppendMethod = + typeof this._placeholderContainer.nativeElement.append === 'function'; + LOG.error( + `Could not create placeholder-container. ` + + `Element-name: ${this._placeholderContainer.nativeElement.tagName}; ` + + `Has append method: ${hasAppendMethod}`, + ex, + ); + } return placeholder; }