1+ import type ApplicationInstance from '@ember/application/instance' ;
12import config from 'test-app/config/environment' ;
23
34// @ts -expect-error Public property 'isFastBoot' of exported class
45const isFastBoot = typeof FastBoot !== 'undefined' ;
56
6- export function initialize ( appInstance ) {
7- if ( config . environment !== 'test' || isFastBoot || ! config . APP . shadowDom ) {
7+ export function initialize ( appInstance : ApplicationInstance ) {
8+ if ( config . environment !== 'test' || isFastBoot || ! config . APP [ ' shadowDom' ] ) {
89 return ;
910 }
1011
11- let appRootElement = appInstance . rootElement ;
12+ let appRootElement = appInstance . rootElement as HTMLElement | null ;
1213
1314 if ( typeof appRootElement === 'string' ) {
14- appRootElement = document . querySelector ( appRootElement ) ;
15+ appRootElement = document . querySelector (
16+ appRootElement ,
17+ ) as HTMLElement | null ;
1518 }
1619 const targetElement =
1720 appRootElement || document . getElementsByTagName ( 'body' ) [ 0 ] ;
@@ -23,11 +26,11 @@ export function initialize(appInstance) {
2326 const wormhole = document . createElement ( 'div' ) ;
2427 wormhole . id = 'ember-basic-dropdown-wormhole' ;
2528
26- hostElement . shadowRoot . appendChild ( wormhole ) ;
27- hostElement . shadowRoot . appendChild ( rootElement ) ;
28- targetElement . appendChild ( hostElement ) ;
29+ hostElement . shadowRoot ? .appendChild ( wormhole ) ;
30+ hostElement . shadowRoot ? .appendChild ( rootElement ) ;
31+ targetElement ? .appendChild ( hostElement ) ;
2932
30- config . APP . rootElement = '#ember-basic-dropdown-wormhole' ;
33+ config . APP [ ' rootElement' ] = '#ember-basic-dropdown-wormhole' ;
3134 appInstance . set ( 'rootElement' , rootElement ) ;
3235}
3336
0 commit comments