Skip to content

Commit 07df410

Browse files
fix(module:statistic): remove top-level redundant div element (#7659)
1 parent 2dcefe2 commit 07df410

2 files changed

Lines changed: 18 additions & 16 deletions

File tree

components/statistic/statistic.component.ts

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,21 +28,23 @@ import { NzStatisticValueType } from './typings';
2828
selector: 'nz-statistic',
2929
exportAs: 'nzStatistic',
3030
template: `
31-
<div class="ant-statistic" [class.ant-statistic-rtl]="dir === 'rtl'">
32-
<div class="ant-statistic-title">
33-
<ng-container *nzStringTemplateOutlet="nzTitle">{{ nzTitle }}</ng-container>
34-
</div>
35-
<div class="ant-statistic-content" [ngStyle]="nzValueStyle">
36-
<span *ngIf="nzPrefix" class="ant-statistic-content-prefix">
37-
<ng-container *nzStringTemplateOutlet="nzPrefix">{{ nzPrefix }}</ng-container>
38-
</span>
39-
<nz-statistic-number [nzValue]="nzValue" [nzValueTemplate]="nzValueTemplate"></nz-statistic-number>
40-
<span *ngIf="nzSuffix" class="ant-statistic-content-suffix">
41-
<ng-container *nzStringTemplateOutlet="nzSuffix">{{ nzSuffix }}</ng-container>
42-
</span>
43-
</div>
31+
<div class="ant-statistic-title">
32+
<ng-container *nzStringTemplateOutlet="nzTitle">{{ nzTitle }}</ng-container>
4433
</div>
45-
`
34+
<div class="ant-statistic-content" [ngStyle]="nzValueStyle">
35+
<span *ngIf="nzPrefix" class="ant-statistic-content-prefix">
36+
<ng-container *nzStringTemplateOutlet="nzPrefix">{{ nzPrefix }}</ng-container>
37+
</span>
38+
<nz-statistic-number [nzValue]="nzValue" [nzValueTemplate]="nzValueTemplate"></nz-statistic-number>
39+
<span *ngIf="nzSuffix" class="ant-statistic-content-suffix">
40+
<ng-container *nzStringTemplateOutlet="nzSuffix">{{ nzSuffix }}</ng-container>
41+
</span>
42+
</div>
43+
`,
44+
host: {
45+
class: 'ant-statistic',
46+
'[class.ant-statistic-rtl]': `dir === 'rtl'`
47+
}
4648
})
4749
export class NzStatisticComponent implements OnDestroy, OnInit {
4850
@Input() nzPrefix?: string | TemplateRef<void>;

components/statistic/statistic.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ describe('nz-statistic', () => {
5151

5252
it('should className correct on dir change', () => {
5353
fixture.detectChanges();
54-
expect(statisticEl.nativeElement.querySelector('.ant-statistic').classList).toContain('ant-statistic-rtl');
54+
expect(statisticEl.nativeElement.classList).toContain('ant-statistic-rtl');
5555

5656
fixture.componentInstance.direction = 'ltr';
5757
fixture.detectChanges();
58-
expect(statisticEl.nativeElement.querySelector('.ant-statistic').classList).not.toContain('ant-statistic-rtl');
58+
expect(statisticEl.nativeElement.classList).not.toContain('ant-statistic-rtl');
5959
});
6060
});
6161
});

0 commit comments

Comments
 (0)