File tree Expand file tree Collapse file tree 1 file changed +9
-6
lines changed
projects/igniteui-angular/src/lib/core Expand file tree Collapse file tree 1 file changed +9
-6
lines changed Original file line number Diff line number Diff line change 2020 */
2121
2222// Note: Originally copied from core-js-pure package and modified. (https://github.com/zloirock/core-js)
23- const windowLocation = window . location ;
24- let counter = 0 ;
23+
2524const queue = { } ;
25+ let counter = 0 ;
26+ let eventListenerAdded = false ;
2627
2728const run = function ( id ) {
2829 if ( queue . hasOwnProperty ( id ) ) {
@@ -36,15 +37,16 @@ const listener = function (event) {
3637 run ( event . data ) ;
3738} ;
3839
39- if ( ! window . setImmediate ) {
40- window . addEventListener ( 'message' , listener , false ) ;
41- }
42-
4340export function setImmediate ( cb : any ) {
4441 if ( window . setImmediate ) {
4542 return window . setImmediate ( cb ) ;
4643 }
4744
45+ if ( ! eventListenerAdded ) {
46+ eventListenerAdded = true ;
47+ window . addEventListener ( 'message' , listener , false ) ;
48+ }
49+
4850 const args = [ ] ;
4951 let i = 1 ;
5052
@@ -56,6 +58,7 @@ export function setImmediate(cb: any) {
5658 ( typeof cb === 'function' ? cb : Function ( cb ) ) . apply ( undefined , args ) ;
5759 } ;
5860
61+ const windowLocation = window . location ;
5962 window . postMessage ( counter + '' , windowLocation . protocol + '//' + windowLocation . host ) ;
6063
6164 return counter ;
You can’t perform that action at this time.
0 commit comments