• 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

12.9
/src/shared/directives/thy-stop-propagation.directive.ts
1
import { Directive, ElementRef, Input, NgZone, OnDestroy } from '@angular/core';
2
import { fromEvent, Observable, Subject } from 'rxjs';
3
import { startWith, switchMap, takeUntil } from 'rxjs/operators';
4

5
/**
6
 * 阻止事件冒泡
7
 * @name thyStopPropagation
8
 */
9
@Directive({
1✔
10
    selector: '[thyStopPropagation]',
11
    standalone: true
×
12
})
×
13
export class ThyStopPropagationDirective implements OnDestroy {
14
    private _eventName = 'click';
15

×
16
    private _shouldStopPropagation = true;
×
17

×
18
    @Input()
19
    set thyStopPropagation(value: string | boolean) {
20
        if (value === false || value === 'false') {
×
21
            this._shouldStopPropagation = false;
22
        } else {
23
            this._shouldStopPropagation = true;
×
24
            if (!value || value === true || value === 'true') {
25
                this._eventName = 'click';
26
            } else {
×
27
                this._eventName = value as string;
×
28
            }
×
29
        }
×
30

×
31
        this._changes$.next();
32
    }
33

×
34
    private _changes$ = new Subject<void>();
35
    private _destroy$ = new Subject<void>();
×
36

×
37
    constructor(_host: ElementRef<HTMLElement>, _ngZone: NgZone) {
38
        this._changes$
39
            .pipe(
40
                // Note: we start the stream immediately since the `thyStopPropagation` setter may never be reached.
41
                startWith<null, null>(null),
×
42
                switchMap(
43
                    () =>
1✔
44
                        new Observable<Event>(subscriber =>
45
                            _ngZone.runOutsideAngular(() => fromEvent(_host.nativeElement, this._eventName).subscribe(subscriber))
46
                        )
47
                ),
1✔
48
                takeUntil(this._destroy$)
49
            )
50
            .subscribe(event => {
51
                if (this._shouldStopPropagation) {
1✔
52
                    event.stopPropagation();
53
                }
54
            });
55
    }
56

57
    ngOnDestroy() {
58
        this._destroy$.next();
59
    }
60
}
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