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