Skip to content

Commit 0099ef9

Browse files
authored
refactor(*): use nullish coalescing instead of || (#1940)
1 parent 79cf1cf commit 0099ef9

File tree

95 files changed

+230
-230
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+230
-230
lines changed

packages/abc/date-picker/range.directive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class RangePickerDirective implements OnDestroy, AfterViewInit {
4949
if (typeof val !== 'object') {
5050
item.enabled = val !== false;
5151
}
52-
(item.list || []).forEach(i => {
52+
(item.list ?? []).forEach(i => {
5353
i._text = this.dom.bypassSecurityTrustHtml(i.text);
5454
});
5555
this._shortcut = item;

packages/abc/down-file/down-file.directive.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export class DownFileDirective {
2727
@Output() readonly error = new EventEmitter<NzSafeAny>();
2828

2929
private getDisposition(data: string | null): NzSafeAny {
30-
const arr: Array<Record<string, string>> = (data || '')
30+
const arr: Array<Record<string, string>> = (data ?? '')
3131
.split(';')
3232
.filter(i => i.includes('='))
3333
.map(v => {
@@ -65,7 +65,7 @@ export class DownFileDirective {
6565
this.setDisabled(true);
6666
this._http
6767
.request(this.httpMethod, this.httpUrl, {
68-
params: this.httpData || {},
68+
params: this.httpData ?? {},
6969
responseType: 'blob',
7070
observe: 'response',
7171
body: this.httpBody

packages/abc/ellipsis/ellipsis.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class EllipsisComponent implements AfterViewInit, OnChanges {
6161
}
6262

6363
private get win(): NzSafeAny {
64-
return this.doc.defaultView || window;
64+
return this.doc.defaultView ?? window;
6565
}
6666

6767
private getStrFullLength(str: string): number {
@@ -169,7 +169,7 @@ export class EllipsisComponent implements AfterViewInit, OnChanges {
169169
} else if (type === 'line') {
170170
const { shadowOrgEl, shadowTextEl } = this;
171171
const orgNode = shadowOrgEl.nativeElement as HTMLElement;
172-
const lineText = orgNode.innerText || orgNode.textContent!;
172+
const lineText = orgNode.innerText ?? orgNode.textContent!;
173173
const lineHeight = parseInt(this.win.getComputedStyle(this.getEl('.ellipsis')).lineHeight!, 10);
174174
const targetHeight = lines! * lineHeight;
175175
const handleEl = this.getEl('.ellipsis__handle');

packages/abc/error-collect/error-collect.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export class ErrorCollectComponent implements OnInit {
7070
if (this.count() === 0) return false;
7171
// nz-form-control
7272
const els = this.errEls;
73-
const formItemEl = this.findParent(els[0], '[nz-form-control]') || els[0];
73+
const formItemEl = this.findParent(els[0], '[nz-form-control]') ?? els[0];
7474
formItemEl.scrollIntoView(true);
7575
// fix header height
7676
this.doc.documentElement.scrollTop -= this.offsetTop();

packages/abc/loading/loading.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class LoadingService implements OnDestroy {
5555
backdropClass: 'loading-backdrop'
5656
});
5757
this.compRef = this._overlayRef.attach(new ComponentPortal(LoadingDefaultComponent));
58-
const dir = this.configSrv.get('loading')!.direction || this.directionality.value;
58+
const dir = this.configSrv.get('loading')!.direction ?? this.directionality.value;
5959
if (this.instance != null) {
6060
this.instance!.options = this.opt;
6161
this.instance!.dir = dir;

packages/abc/lodop/lodop.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ export class LodopService implements OnDestroy {
168168
if (arr != null && Array.isArray(arr) && contextObj) {
169169
for (let i = 0; i < arr.length; i++) {
170170
if (typeof arr[i] === 'string') {
171-
arr[i] = (arr[i] as string).replace(/{{(.*?)}}/g, (_match, key) => contextObj[key.trim()] || '');
171+
arr[i] = (arr[i] as string).replace(/{{(.*?)}}/g, (_match, key) => contextObj[key.trim()] ?? '');
172172
}
173173
}
174174
}

packages/abc/notice-icon/notice-icon-tab.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010
<p>
1111
<ng-container *nzStringTemplateOutlet="d.emptyText">
12-
{{ d.emptyText || locale().emptyText }}
12+
{{ d.emptyText ?? locale().emptyText }}
1313
</ng-container>
1414
</p>
1515
</div>
@@ -45,5 +45,5 @@
4545
</nz-list-item>
4646
</ng-template>
4747
</nz-list>
48-
<div class="notice-icon__clear" (click)="onClear()">{{ d.clearText || locale().clearText }}</div>
48+
<div class="notice-icon__clear" (click)="onClear()">{{ d.clearText ?? locale().clearText }}</div>
4949
</ng-template>

packages/abc/onboarding/onboarding.component.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class OnboardingComponent implements OnDestroy, AfterViewInit {
7474
}
7575

7676
private _getWin(): Window {
77-
return this._getDoc().defaultView || window;
77+
return this._getDoc().defaultView ?? window;
7878
}
7979

8080
private getLightData(): OnboardingLightData | null {
@@ -85,8 +85,8 @@ export class OnboardingComponent implements OnDestroy, AfterViewInit {
8585
return null;
8686
}
8787

88-
const scrollTop = win.scrollY || doc.documentElement.scrollTop || doc.body.scrollTop;
89-
const scrollLeft = win.scrollX || doc.documentElement.scrollLeft || doc.body.scrollLeft;
88+
const scrollTop = win.scrollY ?? doc.documentElement.scrollTop ?? doc.body.scrollTop;
89+
const scrollLeft = win.scrollX ?? doc.documentElement.scrollLeft ?? doc.body.scrollLeft;
9090
const rect = el.getBoundingClientRect();
9191
const top = rect.top + scrollTop;
9292
const left = rect.left + scrollLeft;

packages/abc/onboarding/onboarding.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export class OnboardingService implements OnDestroy {
116116
...this.locale(),
117117
...items[this.active]
118118
} as OnboardingItem;
119-
const dir = this.configSrv.get('onboarding')!.direction || this.directionality.value;
119+
const dir = this.configSrv.get('onboarding')!.direction ?? this.directionality.value;
120120
Object.assign(this.compRef.instance, { item, config: this.config, active: this.active, max: items.length, dir });
121121
const pipes = [
122122
switchMap(() => (item.url ? this.router.navigateByUrl(item.url) : of(true))),

packages/abc/page-header/page-header.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export class PageHeaderComponent implements OnInit, OnChanges, AfterViewInit {
167167
// add home
168168
if (this.home) {
169169
paths.splice(0, 0, {
170-
title: (this.homeI18n && this.i18nSrv.fanyi(this.homeI18n)) || this.home,
170+
title: (this.homeI18n && this.i18nSrv.fanyi(this.homeI18n)) ?? this.home,
171171
link: [this.homeLink!]
172172
});
173173
}

0 commit comments

Comments
 (0)