Skip to content

Commit 1c9bbb9

Browse files
committed
refactor(colors): use 'DOCUMENT' of '@angular/common'
1 parent 026be98 commit 1c9bbb9

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/app/views/theme/colors.component.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
import { Component, OnInit } from '@angular/core';
1+
import { Component, Inject, OnInit } from '@angular/core';
2+
import { DOCUMENT } from '@angular/common';
23
import { getStyle, rgbToHex } from '@coreui/coreui/dist/js/coreui-utilities';
34

45
@Component({
56
templateUrl: 'colors.component.html'
67
})
78
export class ColorsComponent implements OnInit {
8-
public themeColors(): void {
9-
Array.from(document.querySelectorAll('.theme-color')).forEach(function(el) {
10-
const elem = document.getElementsByClassName(el.classList[0])[0];
11-
const background = getStyle('background-color', elem);
9+
constructor(@Inject(DOCUMENT) private _document: any) {}
1210

13-
const table = document.createElement('table');
11+
public themeColors(): void {
12+
Array.from(this._document.querySelectorAll('.theme-color')).forEach((el: HTMLElement) => {
13+
const background = getStyle('background-color', el);
14+
const table = this._document.createElement('table');
1415
table.innerHTML = `
1516
<table class="w-100">
1617
<tr>
@@ -23,10 +24,8 @@ export class ColorsComponent implements OnInit {
2324
</tr>
2425
</table>
2526
`;
26-
2727
el.parentNode.appendChild(table);
2828
});
29-
3029
}
3130

3231
ngOnInit(): void {

0 commit comments

Comments
 (0)