@@ -49,6 +49,7 @@ import {MatLabel} from './label';
49
49
import { MatPlaceholder } from './placeholder' ;
50
50
import { MatPrefix } from './prefix' ;
51
51
import { MatSuffix } from './suffix' ;
52
+ import { Platform } from '@angular/cdk/platform' ;
52
53
53
54
54
55
let nextUniqueId = 0 ;
@@ -218,7 +219,9 @@ export class MatFormField extends _MatFormFieldMixinBase
218
219
@Optional ( ) @Inject ( MAT_LABEL_GLOBAL_OPTIONS ) labelOptions : LabelOptions ,
219
220
@Optional ( ) private _dir : Directionality ,
220
221
@Optional ( ) @Inject ( MAT_FORM_FIELD_DEFAULT_OPTIONS ) private _defaultOptions :
221
- MatFormFieldDefaultOptions ) {
222
+ MatFormFieldDefaultOptions ,
223
+ // @deletion -target 7.0.0 _platform to be made required.
224
+ private _platform ?: Platform ) {
222
225
super ( _elementRef ) ;
223
226
224
227
this . _labelOptions = labelOptions ? labelOptions : { } ;
@@ -415,6 +418,11 @@ export class MatFormField extends _MatFormFieldMixinBase
415
418
*/
416
419
updateOutlineGap ( ) {
417
420
if ( this . appearance === 'outline' && this . _label && this . _label . nativeElement . children . length ) {
421
+ if ( this . _platform && ! this . _platform . isBrowser ) {
422
+ // getBoundingClientRect isn't available on the server.
423
+ return ;
424
+ }
425
+
418
426
const containerStart = this . _getStartEnd (
419
427
this . _connectionContainerRef . nativeElement . getBoundingClientRect ( ) ) ;
420
428
const labelStart = this . _getStartEnd (
0 commit comments