@@ -48,7 +48,9 @@ export abstract class MdcMenuSurfaceBase extends MDCComponent<MDCMenuSurfaceFoun
4848 private _previousFocus : Element | null = null ;
4949
5050 @Input ( )
51- get open ( ) : boolean { return this . _open ; }
51+ get open ( ) : boolean {
52+ return this . _open ;
53+ }
5254 set open ( value : boolean ) {
5355 const newValue = coerceBooleanProperty ( value ) ;
5456 if ( newValue !== this . _open ) {
@@ -59,30 +61,38 @@ export abstract class MdcMenuSurfaceBase extends MDCComponent<MDCMenuSurfaceFoun
5961 private _open : boolean = false ;
6062
6163 @Input ( )
62- get anchorElement ( ) : HTMLElement | null { return this . _anchorElement ; }
64+ get anchorElement ( ) : HTMLElement | null {
65+ return this . _anchorElement ;
66+ }
6367 set anchorElement ( element : HTMLElement | null ) {
6468 this . _anchorElement = element ;
6569 }
6670 private _anchorElement : HTMLElement | null = null ;
6771
6872 @Input ( )
69- get anchorCorner ( ) : AnchorCorner { return this . _anchorCorner ; }
73+ get anchorCorner ( ) : AnchorCorner {
74+ return this . _anchorCorner ;
75+ }
7076 set anchorCorner ( value : AnchorCorner ) {
7177 this . _anchorCorner = value || 'topStart' ;
7278 this . _foundation . setAnchorCorner ( ANCHOR_CORNER_MAP [ this . _anchorCorner ] ) ;
7379 }
7480 private _anchorCorner : AnchorCorner = 'topStart' ;
7581
7682 @Input ( )
77- get quickOpen ( ) : boolean { return this . _quickOpen ; }
83+ get quickOpen ( ) : boolean {
84+ return this . _quickOpen ;
85+ }
7886 set quickOpen ( value : boolean ) {
7987 this . _quickOpen = coerceBooleanProperty ( value ) ;
8088 this . _foundation . setQuickOpen ( this . _quickOpen ) ;
8189 }
8290 private _quickOpen : boolean = false ;
8391
8492 @Input ( )
85- get fixed ( ) : boolean { return this . _fixed ; }
93+ get fixed ( ) : boolean {
94+ return this . _fixed ;
95+ }
8696 set fixed ( value : boolean ) {
8797 this . _fixed = coerceBooleanProperty ( value ) ;
8898 this . _fixed ? this . _getHostElement ( ) . classList . add ( 'mdc-menu-surface--fixed' ) :
@@ -92,23 +102,29 @@ export abstract class MdcMenuSurfaceBase extends MDCComponent<MDCMenuSurfaceFoun
92102 private _fixed : boolean = false ;
93103
94104 @Input ( )
95- get coordinates ( ) : Coordinates { return this . _coordinates ; }
105+ get coordinates ( ) : Coordinates {
106+ return this . _coordinates ;
107+ }
96108 set coordinates ( value : Coordinates ) {
97109 this . _coordinates = value ;
98110 this . _foundation . setAbsolutePosition ( value . x , value . y ) ;
99111 }
100- private _coordinates : Coordinates = { x : 0 , y : 0 } ;
112+ private _coordinates : Coordinates = { x : 0 , y : 0 } ;
101113
102114 @Input ( )
103- get anchorMargin ( ) : AnchorMargin { return this . _anchorMargin ; }
115+ get anchorMargin ( ) : AnchorMargin {
116+ return this . _anchorMargin ;
117+ }
104118 set anchorMargin ( value : AnchorMargin ) {
105119 this . _anchorMargin = value ;
106120 this . _foundation . setAnchorMargin ( this . _anchorMargin ) ;
107121 }
108122 private _anchorMargin : AnchorMargin = { } ;
109123
110124 @Input ( )
111- get hoistToBody ( ) : boolean { return this . _hoistToBody ; }
125+ get hoistToBody ( ) : boolean {
126+ return this . _hoistToBody ;
127+ }
112128 set hoistToBody ( value : boolean ) {
113129 this . _hoistToBody = coerceBooleanProperty ( value ) ;
114130 if ( this . _hoistToBody ) {
@@ -141,56 +157,38 @@ export abstract class MdcMenuSurfaceBase extends MDCComponent<MDCMenuSurfaceFoun
141157 this . _registerWindowClickListener ( ) ;
142158 } ,
143159 isElementInContainer : ( el : Element ) => this . _getHostElement ( ) === el || this . _getHostElement ( ) . contains ( el ) ,
144- isRtl : ( ) => {
145- if ( ! this . platform . isBrowser ) { return false ; }
146-
147- return window . getComputedStyle ( this . _getHostElement ( ) ) . getPropertyValue ( 'direction' ) === 'rtl' ;
148- } ,
149- setTransformOrigin : ( origin : string ) => {
150- if ( ! this . platform . isBrowser ) { return ; }
151-
152- this . _getHostElement ( ) . style [ `${ util . getTransformPropertyName ( window ) } -origin` as any ] = origin ;
153- } ,
160+ isRtl : ( ) => this . platform . isBrowser ?
161+ window . getComputedStyle ( this . _getHostElement ( ) ) . getPropertyValue ( 'direction' ) === 'rtl' : false ,
162+ setTransformOrigin : ( origin : string ) =>
163+ this . platform . isBrowser ?
164+ this . _getHostElement ( ) . style [ `${ util . getTransformPropertyName ( window ) } -origin` as any ] = origin : false ,
154165 isFocused : ( ) => this . platform . isBrowser ? document . activeElement ! === this . _getHostElement ( ) : false ,
155- saveFocus : ( ) => {
156- if ( ! this . platform . isBrowser ) { return ; }
157- this . _previousFocus = document . activeElement ! ;
158- } ,
166+ saveFocus : ( ) => this . platform . isBrowser ? this . _previousFocus = document . activeElement ! : { } ,
159167 restoreFocus : ( ) => {
160- if ( ! this . platform . isBrowser ) { return ; }
161-
162- if ( this . _getHostElement ( ) . contains ( document . activeElement ! ) ) {
168+ if ( ! this . platform . isBrowser && this . _getHostElement ( ) . contains ( document . activeElement ! ) ) {
163169 if ( this . _previousFocus && ( < any > this . _previousFocus ) . focus ) {
164170 ( < any > this . _previousFocus ) . focus ( ) ;
165171 }
166172 }
167173 } ,
168- getInnerDimensions : ( ) => {
169- return { width : this . _getHostElement ( ) . offsetWidth , height : this . _getHostElement ( ) . offsetHeight } ;
170- } ,
171- getAnchorDimensions : ( ) => {
172- if ( ! this . platform . isBrowser || ! this . anchorElement ) { return null ; }
173- return this . _anchorElement ! . getBoundingClientRect ( ) ;
174- } ,
175- getWindowDimensions : ( ) => {
176- return {
177- width : this . platform . isBrowser ? window . innerWidth : 0 ,
178- height : this . platform . isBrowser ? window . innerHeight : 0
179- } ;
180- } ,
181- getBodyDimensions : ( ) => {
182- return {
183- width : this . platform . isBrowser ? document . body ! . clientWidth : 0 ,
184- height : this . platform . isBrowser ? document . body ! . clientHeight : 0
185- } ;
186- } ,
187- getWindowScroll : ( ) => {
188- return {
189- x : this . platform . isBrowser ? window . pageXOffset : 0 ,
190- y : this . platform . isBrowser ? window . pageYOffset : 0
191- } ;
192- } ,
193- setPosition : ( position : { left : number , right : number , top : number , bottom : number } ) => {
174+ getInnerDimensions : ( ) =>
175+ ( { width : this . _getHostElement ( ) . offsetWidth , height : this . _getHostElement ( ) . offsetHeight } ) ,
176+ getAnchorDimensions : ( ) =>
177+ this . platform . isBrowser || ! this . anchorElement ?
178+ this . _anchorElement ! . getBoundingClientRect ( ) : { top : 0 , right : 0 , bottom : 0 , left : 0 , width : 0 , height : 0 } ,
179+ getWindowDimensions : ( ) => ( {
180+ width : this . platform . isBrowser ? window . innerWidth : 0 ,
181+ height : this . platform . isBrowser ? window . innerHeight : 0
182+ } ) ,
183+ getBodyDimensions : ( ) => ( {
184+ width : this . platform . isBrowser ? document . body ! . clientWidth : 0 ,
185+ height : this . platform . isBrowser ? document . body ! . clientHeight : 0
186+ } ) ,
187+ getWindowScroll : ( ) => ( {
188+ x : this . platform . isBrowser ? window . pageXOffset : 0 ,
189+ y : this . platform . isBrowser ? window . pageYOffset : 0
190+ } ) ,
191+ setPosition : ( position : { left : number , right : number , top : number , bottom : number } ) => {
194192 this . _getHostElement ( ) . style . left = 'left' in position ? `${ position . left } px` : '' ;
195193 this . _getHostElement ( ) . style . right = 'right' in position ? `${ position . right } px` : '' ;
196194 this . _getHostElement ( ) . style . top = 'top' in position ? `${ position . top } px` : '' ;
@@ -206,7 +204,6 @@ export abstract class MdcMenuSurfaceBase extends MDCComponent<MDCMenuSurfaceFoun
206204 public platform : Platform ,
207205 @Optional ( ) private _ngZone : NgZone ,
208206 public elementRef : ElementRef < HTMLElement > ) {
209-
210207 super ( elementRef ) ;
211208 }
212209
@@ -233,14 +230,16 @@ export abstract class MdcMenuSurfaceBase extends MDCComponent<MDCMenuSurfaceFoun
233230
234231 protected setOpen ( ) : void {
235232 this . _open ? this . _foundation . open ( ) : this . _foundation . close ( ) ;
236- }
233+ }
237234
238235 /**
239236 * Removes the menu-surface from it's current location and appends it to the
240237 * body to overcome any overflow:hidden issues.
241238 */
242239 protected setHoistToBody ( ) : void {
243- if ( ! this . platform . isBrowser ) { return ; }
240+ if ( ! this . platform . isBrowser ) {
241+ return ;
242+ }
244243
245244 const parentEl = this . _getHostElement ( ) . parentElement ;
246245 if ( parentEl ) {
@@ -256,7 +255,9 @@ export abstract class MdcMenuSurfaceBase extends MDCComponent<MDCMenuSurfaceFoun
256255 }
257256
258257 private _registerWindowClickListener ( ) : void {
259- if ( ! this . platform . isBrowser ) { return ; }
258+ if ( ! this . platform . isBrowser ) {
259+ return ;
260+ }
260261
261262 this . _windowClickSubscription =
262263 this . _ngZone . runOutsideAngular ( ( ) =>
0 commit comments