From 8c13325ea6dac0322c5e07613be24247ec9cd134 Mon Sep 17 00:00:00 2001 From: Jeremy Elbourn Date: Tue, 11 Jul 2017 09:25:54 -0700 Subject: [PATCH] fix(bidi): make `dir` and `changes` readonly (#5645) --- src/cdk/bidi/dir.ts | 11 +++-------- src/cdk/bidi/directionality.ts | 4 ++-- src/demo-app/demo-app/demo-app.html | 2 +- src/lib/tabs/tab-header.spec.ts | 4 ++-- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/cdk/bidi/dir.ts b/src/cdk/bidi/dir.ts index b25d6418b1ad..31bf0c489f1f 100644 --- a/src/cdk/bidi/dir.ts +++ b/src/cdk/bidi/dir.ts @@ -8,7 +8,6 @@ import { Directive, - HostBinding, Output, Input, EventEmitter @@ -23,11 +22,9 @@ import {Direction, Directionality} from './directionality'; */ @Directive({ selector: '[dir]', - // TODO(hansl): maybe `$implicit` isn't the best option here, but for now that's the best we got. - exportAs: '$implicit', - providers: [ - {provide: Directionality, useExisting: Dir} - ] + providers: [{provide: Directionality, useExisting: Dir}], + host: {'[dir]': 'dir'}, + exportAs: 'dir', }) export class Dir implements Directionality { /** Layout direction of the element. */ @@ -40,7 +37,6 @@ export class Dir implements Directionality { @Output('dirChange') change = new EventEmitter(); /** @docs-private */ - @HostBinding('attr.dir') @Input('dir') get dir(): Direction { return this._dir; @@ -56,7 +52,6 @@ export class Dir implements Directionality { /** Current layout direction of the element. */ get value(): Direction { return this.dir; } - set value(v: Direction) { this.dir = v; } /** Initialize once default value has been set. */ ngAfterContentInit() { diff --git a/src/cdk/bidi/directionality.ts b/src/cdk/bidi/directionality.ts index c0c4be344e9a..90cd0eaed2a4 100644 --- a/src/cdk/bidi/directionality.ts +++ b/src/cdk/bidi/directionality.ts @@ -37,8 +37,8 @@ export const DIR_DOCUMENT = new InjectionToken('md-dir-doc'); */ @Injectable() export class Directionality { - value: Direction = 'ltr'; - change = new EventEmitter(); + readonly value: Direction = 'ltr'; + readonly change = new EventEmitter(); constructor(@Optional() @Inject(DIR_DOCUMENT) _document?: any) { if (_document) { diff --git a/src/demo-app/demo-app/demo-app.html b/src/demo-app/demo-app/demo-app.html index 181cbca273c3..96d76215bd72 100644 --- a/src/demo-app/demo-app/demo-app.html +++ b/src/demo-app/demo-app/demo-app.html @@ -40,7 +40,7 @@

Angular Material Demos

-
+
diff --git a/src/lib/tabs/tab-header.spec.ts b/src/lib/tabs/tab-header.spec.ts index 1d39fc749a21..c7881a543644 100644 --- a/src/lib/tabs/tab-header.spec.ts +++ b/src/lib/tabs/tab-header.spec.ts @@ -210,10 +210,10 @@ describe('MdTabHeader', () => { beforeEach(() => { dir = 'rtl'; fixture = TestBed.createComponent(SimpleTabHeaderApp); - fixture.detectChanges(); - appComponent = fixture.componentInstance; appComponent.dir = 'rtl'; + + fixture.detectChanges(); }); it('should scroll to show the focused tab label', () => {