@@ -30,21 +30,22 @@ import {takeUntil} from 'rxjs/operators';
30
30
31
31
export interface ShowHideParent {
32
32
display : string ;
33
+ isServer : boolean ;
33
34
}
34
35
35
36
@Injectable ( { providedIn : 'root' } )
36
37
export class ShowHideStyleBuilder extends StyleBuilder {
37
38
buildStyles ( show : string , parent : ShowHideParent ) {
38
39
const shouldShow = show === 'true' ;
39
- return { 'display' : shouldShow ? parent . display : 'none' } ;
40
+ return { 'display' : shouldShow ? parent . display || ( parent . isServer ? 'initial' : '' ) : 'none' } ;
40
41
}
41
42
}
42
43
43
44
@Directive ( )
44
45
export class ShowHideDirective extends BaseDirective2 implements AfterViewInit , OnChanges {
45
46
protected DIRECTIVE_KEY = 'show-hide' ;
46
47
47
- /** Original dom Elements CSS display style */
48
+ /** Original DOM Element CSS display style */
48
49
protected display : string = '' ;
49
50
protected hasLayout = false ;
50
51
protected hasFlexChild = false ;
@@ -146,8 +147,9 @@ export class ShowHideDirective extends BaseDirective2 implements AfterViewInit,
146
147
if ( value === '' ) {
147
148
return ;
148
149
}
149
- this . addStyles ( value ? 'true' : 'false' , { display : this . display } ) ;
150
- if ( isPlatformServer ( this . platformId ) && this . serverModuleLoaded ) {
150
+ const isServer = isPlatformServer ( this . platformId ) ;
151
+ this . addStyles ( value ? 'true' : 'false' , { display : this . display , isServer} ) ;
152
+ if ( isServer && this . serverModuleLoaded ) {
151
153
this . nativeElement . style . setProperty ( 'display' , '' ) ;
152
154
}
153
155
this . marshal . triggerUpdate ( this . parentElement ! , 'layout-gap' ) ;
0 commit comments