• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

atinc / ngx-tethys / d9ae709b-3c27-4b69-b125-b8b80b54f90b

pending completion
d9ae709b-3c27-4b69-b125-b8b80b54f90b

Pull #2757

circleci

mengshuicmq
fix: fix code review
Pull Request #2757: feat(color-picker): color-picker support disabled (#INFR-8645)

98 of 6315 branches covered (1.55%)

Branch coverage included in aggregate %.

1 of 1 new or added line in 1 file covered. (100.0%)

2392 of 13661 relevant lines covered (17.51%)

83.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

6.82
/src/core/update-host-class.service.ts
1
import { Injectable, Renderer2, ElementRef } from '@angular/core';
2
import { Dictionary } from 'ngx-tethys/types';
3

1✔
4
@Injectable()
5
export class UpdateHostClassService {
×
6
    private _classNames: string[] = [];
×
7

8
    private _hostElement: HTMLElement;
9

×
10
    constructor(private renderer: Renderer2) {}
×
11

12
    initializeElement(element: HTMLElement | ElementRef<HTMLElement>) {
13
        if (element instanceof ElementRef) {
×
14
            this._hostElement = element.nativeElement;
15
        } else {
×
16
            this._hostElement = element;
17
        }
18
        return this;
×
19
    }
×
20

×
21
    updateClass(classNames: string[]) {
×
22
        if (this._classNames) {
23
            this._classNames.forEach(className => {
24
                if (classNames.indexOf(className) < 0) {
25
                    this.removeClass(className);
×
26
                }
×
27
            });
×
28
        }
×
29
        const newClasses: string[] = [];
×
30
        classNames.forEach(className => {
×
31
            if (className) {
32
                newClasses.push(className);
33
                if (this._classNames.indexOf(className) < 0) {
34
                    this.addClass(className);
×
35
                }
×
36
            }
37
        });
38
        this._classNames = newClasses;
×
39
        return this;
×
40
    }
×
41

×
42
    updateClassByMap(classMap: Dictionary<boolean>) {
43
        const newClasses = [];
44
        for (const key in classMap) {
×
45
            if (classMap.hasOwnProperty(key) && classMap[key]) {
46
                newClasses.push(key);
47
            }
×
48
        }
×
49
        this.updateClass(newClasses);
50
    }
51

×
52
    addClass(className: string) {
×
53
        this.renderer.addClass(this._hostElement, className);
54
        return this;
1✔
55
    }
56

57
    removeClass(className: string) {
58
        this.renderer.removeClass(this._hostElement, className);
1✔
59
        return this;
60
    }
61
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc