File tree Expand file tree Collapse file tree 3 files changed +27
-6
lines changed Expand file tree Collapse file tree 3 files changed +27
-6
lines changed Original file line number Diff line number Diff line change @@ -181,12 +181,19 @@ try {
181181 } ;
182182}
183183
184+ let globalPromise = null ;
185+ if ( typeof window !== 'undefined' ) {
186+ globalPromise = window . Promise ;
187+ } else if ( typeof global !== 'undefined' ) {
188+ globalPromise = global . Promise ;
189+ }
190+
184191function runCallbackUntilPredicateFails (
185192 callback : ( ) = > void ,
186193 predicate : ( ) = > boolean ,
187194) {
188- // eslint-disable-next-line no-undef
189- return new Promise ( ( resolve , reject ) => {
195+ // $FlowFixMe - if we've reached this far, we're certain Promise is available
196+ return new globalPromise ( ( resolve , reject ) => {
190197 callback ( ) ;
191198 enqueueTask ( ( ) => {
192199 if ( predicate ( ) ) {
Original file line number Diff line number Diff line change @@ -996,12 +996,19 @@ try {
996996 } ;
997997}
998998
999+ let globalPromise = null ;
1000+ if ( typeof window !== 'undefined' ) {
1001+ globalPromise = window . Promise ;
1002+ } else if ( typeof global !== 'undefined' ) {
1003+ globalPromise = global . Promise ;
1004+ }
1005+
9991006function runCallbackUntilPredicateFails (
10001007 callback : ( ) = > void ,
10011008 predicate : ( ) = > boolean ,
10021009) {
1003- // eslint-disable-next-line no-undef
1004- return new Promise ( ( resolve , reject ) => {
1010+ // $FlowFixMe - if we've reached this far, we're certain Promise is available
1011+ return new globalPromise ( ( resolve , reject ) => {
10051012 callback ( ) ;
10061013 enqueueTask ( ( ) => {
10071014 if ( predicate ( ) ) {
Original file line number Diff line number Diff line change @@ -628,12 +628,19 @@ try {
628628 } ;
629629}
630630
631+ let globalPromise = null ;
632+ if ( typeof window !== 'undefined' ) {
633+ globalPromise = window . Promise ;
634+ } else if ( typeof global !== 'undefined' ) {
635+ globalPromise = global . Promise ;
636+ }
637+
631638function runCallbackUntilPredicateFails (
632639 callback : ( ) = > void ,
633640 predicate : ( ) = > boolean ,
634641) {
635- // eslint-disable-next-line no-undef
636- return new Promise ( ( resolve , reject ) => {
642+ // $FlowFixMe - if we've reached this far, we're certain Promise is available
643+ return new globalPromise ( ( resolve , reject ) => {
637644 callback ( ) ;
638645 enqueueTask ( ( ) => {
639646 if ( predicate ( ) ) {
You can’t perform that action at this time.
0 commit comments