Skip to content

Commit 49dfe60

Browse files
crisbetojelbourn
authored andcommitted
fix(directionality): error on platform-server (#5234)
1 parent 1a03ee1 commit 49dfe60

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/lib/core/bidi/directionality.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,14 @@ export class Directionality {
4141
change = new EventEmitter<void>();
4242

4343
constructor(@Optional() @Inject(DIR_DOCUMENT) _document?: any) {
44-
if (typeof _document === 'object' && !!_document) {
44+
if (_document) {
4545
// TODO: handle 'auto' value -
4646
// We still need to account for dir="auto".
4747
// It looks like HTMLElemenet.dir is also "auto" when that's set to the attribute,
4848
// but getComputedStyle return either "ltr" or "rtl". avoiding getComputedStyle for now
49-
// though, we're already calling it for the theming check.
50-
this.value = (_document.body.dir || _document.documentElement.dir || 'ltr') as Direction;
49+
const bodyDir = _document.body ? _document.body.dir : null;
50+
const htmlDir = _document.documentElement ? _document.documentElement.dir : null;
51+
this.value = (bodyDir || htmlDir || 'ltr') as Direction;
5152
}
5253
}
5354
}

0 commit comments

Comments
 (0)