fix(bidi): make dir and changes readonly (#5645)

This commit is contained in:
Jeremy Elbourn
2017-07-11 09:25:54 -07:00
committed by GitHub
parent 72148c0657
commit 8c13325ea6
4 changed files with 8 additions and 13 deletions
+3 -8
View File
@@ -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<void>();
/** @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() {
+2 -2
View File
@@ -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) {
+1 -1
View File
@@ -40,7 +40,7 @@
</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>
+2 -2
View File
@@ -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', () => {