@@ -84,12 +84,12 @@ export abstract class PeekViewWidget extends ZoneWidget {
8484
8585 private _onDidClose = new Emitter < PeekViewWidget > ( ) ;
8686
87- protected _headElement : HTMLDivElement ;
88- protected _primaryHeading : HTMLElement ;
89- protected _secondaryHeading : HTMLElement ;
90- protected _metaHeading : HTMLElement ;
91- protected _actionbarWidget : ActionBar ;
92- protected _bodyElement : HTMLDivElement ;
87+ protected _headElement ? : HTMLDivElement ;
88+ protected _primaryHeading ? : HTMLElement ;
89+ protected _secondaryHeading ? : HTMLElement ;
90+ protected _metaHeading ? : HTMLElement ;
91+ protected _actionbarWidget ? : ActionBar ;
92+ protected _bodyElement ? : HTMLDivElement ;
9393
9494 constructor ( editor : ICodeEditor , options : IPeekViewOptions = { } ) {
9595 super ( editor , options ) ;
@@ -139,8 +139,8 @@ export abstract class PeekViewWidget extends ZoneWidget {
139139 protected _fillContainer ( container : HTMLElement ) : void {
140140 this . setCssClass ( 'peekview-widget' ) ;
141141
142- this . _headElement = dom . $ ( '.head' ) ;
143- this . _bodyElement = dom . $ ( '.body' ) ;
142+ this . _headElement = dom . $ < HTMLDivElement > ( '.head' ) ;
143+ this . _bodyElement = dom . $ < HTMLDivElement > ( '.body' ) ;
144144
145145 this . _fillHead ( this . _headElement ) ;
146146 this . _fillBody ( this . _bodyElement ) ;
@@ -151,7 +151,7 @@ export abstract class PeekViewWidget extends ZoneWidget {
151151
152152 protected _fillHead ( container : HTMLElement ) : void {
153153 const titleElement = dom . $ ( '.peekview-title' ) ;
154- dom . append ( this . _headElement , titleElement ) ;
154+ dom . append ( this . _headElement ! , titleElement ) ;
155155 dom . addStandardDisposableListener ( titleElement , 'click' , event => this . _onTitleClick ( event ) ) ;
156156
157157 this . _fillTitleIcon ( titleElement ) ;
@@ -161,7 +161,7 @@ export abstract class PeekViewWidget extends ZoneWidget {
161161 dom . append ( titleElement , this . _primaryHeading , this . _secondaryHeading , this . _metaHeading ) ;
162162
163163 const actionsContainer = dom . $ ( '.peekview-actions' ) ;
164- dom . append ( this . _headElement , actionsContainer ) ;
164+ dom . append ( this . _headElement ! , actionsContainer ) ;
165165
166166 const actionBarOptions = this . _getActionBarOptions ( ) ;
167167 this . _actionbarWidget = new ActionBar ( actionsContainer , actionBarOptions ) ;
@@ -185,20 +185,24 @@ export abstract class PeekViewWidget extends ZoneWidget {
185185 }
186186
187187 public setTitle ( primaryHeading : string , secondaryHeading ?: string ) : void {
188- this . _primaryHeading . innerHTML = strings . escape ( primaryHeading ) ;
189- this . _primaryHeading . setAttribute ( 'aria-label' , primaryHeading ) ;
190- if ( secondaryHeading ) {
191- this . _secondaryHeading . innerHTML = strings . escape ( secondaryHeading ) ;
192- } else {
193- dom . clearNode ( this . _secondaryHeading ) ;
188+ if ( this . _primaryHeading && this . _secondaryHeading ) {
189+ this . _primaryHeading . innerHTML = strings . escape ( primaryHeading ) ;
190+ this . _primaryHeading . setAttribute ( 'aria-label' , primaryHeading ) ;
191+ if ( secondaryHeading ) {
192+ this . _secondaryHeading . innerHTML = strings . escape ( secondaryHeading ) ;
193+ } else {
194+ dom . clearNode ( this . _secondaryHeading ) ;
195+ }
194196 }
195197 }
196198
197199 public setMetaTitle ( value : string ) : void {
198- if ( value ) {
199- this . _metaHeading . innerHTML = strings . escape ( value ) ;
200- } else {
201- dom . clearNode ( this . _metaHeading ) ;
200+ if ( this . _metaHeading ) {
201+ if ( value ) {
202+ this . _metaHeading . innerHTML = strings . escape ( value ) ;
203+ } else {
204+ dom . clearNode ( this . _metaHeading ) ;
205+ }
202206 }
203207 }
204208
@@ -220,11 +224,15 @@ export abstract class PeekViewWidget extends ZoneWidget {
220224 }
221225
222226 protected _doLayoutHead ( heightInPixel : number , widthInPixel : number ) : void {
223- this . _headElement . style . height = `${ heightInPixel } px` ;
224- this . _headElement . style . lineHeight = this . _headElement . style . height ;
227+ if ( this . _headElement ) {
228+ this . _headElement . style . height = `${ heightInPixel } px` ;
229+ this . _headElement . style . lineHeight = this . _headElement . style . height ;
230+ }
225231 }
226232
227233 protected _doLayoutBody ( heightInPixel : number , widthInPixel : number ) : void {
228- this . _bodyElement . style . height = `${ heightInPixel } px` ;
234+ if ( this . _bodyElement ) {
235+ this . _bodyElement . style . height = `${ heightInPixel } px` ;
236+ }
229237 }
230238}
0 commit comments