# All files / src/lib/config custom-cdk-overlay.ts

40.74% Statements 11/27
31.25% Branches 10/32
20% Functions 1/5
31.81% Lines 7/22

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    311x
    1x
    1x
    1x
    1x

    1x

     import { OverlayContainer } from '@angular/cdk/overlay';
    import { Injectable } from '@angular/core';
    I
    @Injectable()
    export class CdkOverlayContainer extends OverlayContainer {
    	containerSelector = '.sidenav-main';
    	customClass = 'cdk-overlay-container';
    	protected _createContainer(): void {
    		const container = document.createElement('div');
    		container.classList.add(this.customClass);
    		let element = this.getElement(this.containerSelector);
    		if (!element) {
    			element = this.getElement('body');
    		}
    		this._containerElement = element.appendChild(container);
    	}

    	setSelector(selector: string) {
    		const overlayElement = this.getElement('.' + this.customClass);

    		if (overlayElement && this.containerSelector !== selector) {
    			const newContainerOverlayContainer = this.getElement(selector);
    			this.containerSelector = selector;
    			newContainerOverlayContainer?.appendChild(overlayElement);
    		}
    	}
    	private getElement(selector: string): Element {
    		return document.querySelector(selector);
    	}
    }