Skip to content

Commit

Permalink
fix(container-breakpoint-observer): Added logging information where t…
Browse files Browse the repository at this point in the history
…he placeholder container is applied so tracking this issue if it is occurring again is easier.

Solves dynatrace-oss#1526
  • Loading branch information
thomaspink authored and Yngrid Coello committed Nov 9, 2020
1 parent 3bec04c commit 9e6e0ab
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
} from '@angular/core';
import { Observable, Observer, Subject, combineLatest } from 'rxjs';
import { map, takeUntil } from 'rxjs/operators';
import { DtLogger, DtLoggerFactory } from '@dynatrace/barista-components/core';

import { getDtContainerBreakpointObserverInvalidQueryError } from './container-breakpoint-observer-errors';
import {
Expand All @@ -37,6 +38,8 @@ import {
isElementQuery,
} from './query';

const LOG: DtLogger = DtLoggerFactory.create('DtContainerBreakpointObserver');

/**
* @internal
* Representation of a query string.
Expand Down Expand Up @@ -273,7 +276,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;
}
Expand Down

0 comments on commit 9e6e0ab

Please sign in to comment.