@@ -1147,26 +1147,51 @@ class ApplicationListener {
11471147}
11481148var applicationListeners = new Map ( ) ;
11491149function registerApplicationListener ( name , listener ) {
1150+ if ( name == null || ( typeof name === 'string' && name . trim ( ) === '' ) ) {
1151+ return false ;
1152+ }
1153+ if ( listener == null || typeof listener !== 'object' ) {
1154+ return false ;
1155+ }
11501156 if ( applicationListeners . has ( name ) ) {
11511157 return false ;
11521158 }
11531159 applicationListeners . set ( name , listener ) ;
1160+ return true ;
11541161}
11551162function unregisterApplicationListener ( name ) {
11561163 applicationListeners . delete ( name ) ;
11571164}
11581165function notifyOnRefresh ( ) {
1159- for ( const [ name , listener ] of applicationListeners ) {
1160- listener . onRefresh ( ) ;
1166+ for ( const [ _name , listener ] of applicationListeners ) {
1167+ if ( listener && typeof listener . onRefresh === 'function' ) {
1168+ try {
1169+ listener . onRefresh ( ) ;
1170+ } catch ( err ) {
1171+ console . error ( `ApplicationListener failed due to ${ err } ` ) ;
1172+ }
1173+ }
11611174 }
11621175}
11631176function notifyOnVhostChange ( newVhost ) {
11641177 for ( const [ _name , listener ] of applicationListeners ) {
1165- listener . onVhostChange ( newVhost ) ;
1178+ if ( listener && typeof listener . onVhostChange === 'function' ) {
1179+ try {
1180+ listener . onVhostChange ( newVhost ) ;
1181+ } catch ( err ) {
1182+ console . error ( `ApplicationListener failed due to ${ err } ` ) ;
1183+ }
1184+ }
11661185 }
11671186}
11681187function notifyActivatedTab ( tab ) {
11691188 for ( const [ _name , listener ] of applicationListeners ) {
1170- listener . onTabActivated ( tab ) ;
1189+ if ( listener && typeof listener . onTabActivated === 'function' ) {
1190+ try {
1191+ listener . onTabActivated ( tab ) ;
1192+ } catch ( err ) {
1193+ console . error ( `ApplicationListener failed due to ${ err } ` ) ;
1194+ }
1195+ }
11711196 }
11721197}
0 commit comments