Skip to content

Commit 87c9d46

Browse files
committed
[DSC-472] Replace document object with inject token
1 parent 7078fd8 commit 87c9d46

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/app/shared/context-menu/context-menu.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, Injector, Input, OnInit } from '@angular/core';
1+
import { Component, Inject, Injector, Input, OnInit } from '@angular/core';
22

33
import { select, Store } from '@ngrx/store';
44
import { from, Observable } from 'rxjs';
@@ -17,6 +17,7 @@ import { ContextMenuEntryType } from './context-menu-entry-type';
1717
import { isNotEmpty } from '../empty.util';
1818
import { ConfigurationDataService } from '../../core/data/configuration-data.service';
1919
import { GenericConstructor } from '../../core/shared/generic-constructor';
20+
import { DOCUMENT } from '@angular/common';
2021

2122
/**
2223
* This component renders a context menu for a given DSO.
@@ -59,11 +60,13 @@ export class ContextMenuComponent implements OnInit {
5960
/**
6061
* Initialize instance variables
6162
*
63+
* @param {Document} _document
6264
* @param {ConfigurationDataService} configurationService
6365
* @param {Injector} injector
6466
* @param {Store<CoreState>} store
6567
*/
6668
constructor(
69+
@Inject(DOCUMENT) private _document: Document,
6770
private configurationService: ConfigurationDataService,
6871
private injector: Injector,
6972
private store: Store<CoreState>
@@ -133,8 +136,8 @@ export class ContextMenuComponent implements OnInit {
133136

134137
ngAfterViewChecked() {
135138
// To check that Context-menu contains options or not
136-
if (document.getElementById('itemOptionsDropdownMenu')) {
137-
const el = Array.from(document.getElementById('itemOptionsDropdownMenu')?.getElementsByClassName('ng-star-inserted'));
139+
if (this._document.getElementById('itemOptionsDropdownMenu')) {
140+
const el = Array.from(this._document.getElementById('itemOptionsDropdownMenu')?.getElementsByClassName('ng-star-inserted'));
138141
this.optionCount = 0;
139142
if (el) {
140143
el.forEach(element => {

0 commit comments

Comments
 (0)