@@ -7,6 +7,8 @@ async function __preloadPopper() {
77}
88export class LocalOverlayController {
99 constructor ( params = { } ) {
10+ this . __fakeExtendsEventTarget ( ) ;
11+
1012 // TODO: Instead of in constructor, prefetch it or use a preloader-manager to load it during idle time
1113 this . constructor . popperModule = __preloadPopper ( ) ;
1214 this . __mergePopperConfigs ( params . popperConfig || { } ) ;
@@ -165,11 +167,19 @@ export class LocalOverlayController {
165167 if ( this . trapsKeyboardFocus ) this . _setupTrapsKeyboardFocus ( ) ;
166168 if ( this . hidesOnOutsideClick ) this . _setupHidesOnOutsideClick ( ) ;
167169 if ( this . hidesOnEsc ) this . _setupHidesOnEsc ( ) ;
170+
171+ if ( this . _prevShown === false ) {
172+ this . dispatchEvent ( new Event ( 'show' ) ) ;
173+ }
168174 } else {
169175 this . _updateContent ( ) ;
170176 this . invokerNode . setAttribute ( 'aria-expanded' , false ) ;
171177 if ( this . hidesOnOutsideClick ) this . _teardownHidesOnOutsideClick ( ) ;
172178 if ( this . hidesOnEsc ) this . _teardownHidesOnEsc ( ) ;
179+
180+ if ( this . _prevShown === true ) {
181+ this . dispatchEvent ( new Event ( 'hide' ) ) ;
182+ }
173183 }
174184 this . _prevShown = shown ;
175185 this . _prevData = data ;
@@ -301,4 +311,13 @@ export class LocalOverlayController {
301311 ...this . popperConfig ,
302312 } ) ;
303313 }
314+
315+ // TODO: this method has to be removed when EventTarget polyfill is available on IE11
316+ // issue: https://gitlab.ing.net/TheGuideComponents/lion-element/issues/12
317+ __fakeExtendsEventTarget ( ) {
318+ const delegate = document . createDocumentFragment ( ) ;
319+ [ 'addEventListener' , 'dispatchEvent' , 'removeEventListener' ] . forEach ( funcName => {
320+ this [ funcName ] = ( ...args ) => delegate [ funcName ] ( ...args ) ;
321+ } ) ;
322+ }
304323}
0 commit comments