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

atinc / ngx-tethys / 68ef226c-f83e-44c1-b8ed-e420a83c5d84

28 May 2025 10:31AM UTC coverage: 10.352% (-80.0%) from 90.316%
68ef226c-f83e-44c1-b8ed-e420a83c5d84

Pull #3460

circleci

pubuzhixing8
chore: xxx
Pull Request #3460: refactor(icon): migrate signal input #TINFR-1476

132 of 6823 branches covered (1.93%)

Branch coverage included in aggregate %.

10 of 14 new or added lines in 1 file covered. (71.43%)

11648 existing lines in 344 files now uncovered.

2078 of 14525 relevant lines covered (14.31%)

6.69 hits per line

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

12.12
/src/shared/directives/thy-stop-propagation.directive.ts
1
import { Directive, ElementRef, Input, NgZone, OnDestroy, inject } 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]'
UNCOV
11
})
×
UNCOV
12
export class ThyStopPropagationDirective implements OnDestroy {
×
13
    private _eventName = 'click';
14

UNCOV
15
    private _shouldStopPropagation = true;
×
UNCOV
16

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

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

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

×
36
    constructor() {
UNCOV
37
        const _host = inject<ElementRef<HTMLElement>>(ElementRef);
×
UNCOV
38
        const _ngZone = inject(NgZone);
×
39

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

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