Skip to content

Commit

Permalink
fix(bidi): make dir and changes readonly (#5645)
Browse files Browse the repository at this point in the history
  • Loading branch information
jelbourn committed Jul 11, 2017
1 parent 72148c0 commit 8c13325
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
11 changes: 3 additions & 8 deletions src/cdk/bidi/dir.ts
Expand Up @@ -8,7 +8,6 @@

import {
Directive,
HostBinding,
Output,
Input,
EventEmitter
Expand All @@ -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. */
Expand All @@ -40,7 +37,6 @@ export class Dir implements Directionality {
@Output('dirChange') change = new EventEmitter<void>();

/** @docs-private */
@HostBinding('attr.dir')
@Input('dir')
get dir(): Direction {
return this._dir;
Expand All @@ -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() {
Expand Down
4 changes: 2 additions & 2 deletions src/cdk/bidi/directionality.ts
Expand Up @@ -37,8 +37,8 @@ export const DIR_DOCUMENT = new InjectionToken<Document>('md-dir-doc');
*/
@Injectable()
export class Directionality {
value: Direction = 'ltr';
change = new EventEmitter<void>();
readonly value: Direction = 'ltr';
readonly change = new EventEmitter<void>();

constructor(@Optional() @Inject(DIR_DOCUMENT) _document?: any) {
if (_document) {
Expand Down
2 changes: 1 addition & 1 deletion src/demo-app/demo-app/demo-app.html
Expand Up @@ -40,7 +40,7 @@ <h1>Angular Material Demos</h1>
</div>
</md-toolbar>

<div #root="$implicit" dir="ltr" class="demo-content" [ngSwitch]="changeDetectionStrategy">
<div #root="dir" dir="ltr" class="demo-content" [ngSwitch]="changeDetectionStrategy">
<div *ngSwitchDefault>
<router-outlet></router-outlet>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/lib/tabs/tab-header.spec.ts
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 8c13325

Please sign in to comment.