mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
fix(directionality): error on platform-server (#5234)
This commit is contained in:
committed by
Jeremy Elbourn
parent
1a03ee15b3
commit
49dfe60387
@@ -41,13 +41,14 @@ export class Directionality {
|
||||
change = new EventEmitter<void>();
|
||||
|
||||
constructor(@Optional() @Inject(DIR_DOCUMENT) _document?: any) {
|
||||
if (typeof _document === 'object' && !!_document) {
|
||||
if (_document) {
|
||||
// TODO: handle 'auto' value -
|
||||
// We still need to account for dir="auto".
|
||||
// It looks like HTMLElemenet.dir is also "auto" when that's set to the attribute,
|
||||
// but getComputedStyle return either "ltr" or "rtl". avoiding getComputedStyle for now
|
||||
// though, we're already calling it for the theming check.
|
||||
this.value = (_document.body.dir || _document.documentElement.dir || 'ltr') as Direction;
|
||||
const bodyDir = _document.body ? _document.body.dir : null;
|
||||
const htmlDir = _document.documentElement ? _document.documentElement.dir : null;
|
||||
this.value = (bodyDir || htmlDir || 'ltr') as Direction;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user