Skip to content

Commit

Permalink
fix(module:carousel): throw error when changing rtl (#6318)
Browse files Browse the repository at this point in the history
close #6301
  • Loading branch information
wenqi73 authored Jan 7, 2021
1 parent a2cc9a7 commit bef7e29
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
4 changes: 1 addition & 3 deletions components/carousel/carousel.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ const NZ_CONFIG_MODULE_NAME: NzConfigKey = 'carousel';
</ng-template>
`,
host: {
'[class.ant-carousel-vertical]': 'vertical',
'[class.ant-carousel-rtl]': `dir ==='rtl'`
'[class.ant-carousel-vertical]': 'vertical'
}
})
export class NzCarouselComponent implements AfterContentInit, AfterViewInit, OnDestroy, OnChanges, OnInit {
Expand Down Expand Up @@ -173,7 +172,6 @@ export class NzCarouselComponent implements AfterContentInit, AfterViewInit, OnD
this.dir = this.directionality.value;
this.directionality.change?.pipe(takeUntil(this.destroy$)).subscribe((direction: Direction) => {
this.dir = direction;
this.switchStrategy();
});
}

Expand Down
21 changes: 0 additions & 21 deletions components/carousel/carousel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,27 +277,6 @@ describe('carousel', () => {
// Already covered in components specs.
// describe('opacity strategy', () => {});
});

describe('RTL', () => {
let fixture: ComponentFixture<NzTestCarouselRtlComponent>;
let carouselWrapper: DebugElement;

beforeEach(() => {
fixture = TestBed.createComponent(NzTestCarouselRtlComponent);
fixture.detectChanges();
carouselWrapper = fixture.debugElement.query(By.directive(NzCarouselComponent));
});

it('should className correct', () => {
fixture.detectChanges();
expect(carouselWrapper.nativeElement.classList).toContain('ant-carousel-rtl');

fixture.componentInstance.direction = 'ltr';
fixture.detectChanges();

expect(carouselWrapper.nativeElement.classList).not.toContain('ant-carousel-rtl');
});
});
});

describe('carousel custom strategies', () => {
Expand Down

0 comments on commit bef7e29

Please sign in to comment.