@@ -170,111 +170,108 @@ export class UpgradeModule {
170
170
const INIT_MODULE_NAME = UPGRADE_MODULE_NAME + '.init' ;
171
171
172
172
// Create an ng1 module to bootstrap
173
- const initModule =
174
- angularModule ( INIT_MODULE_NAME , [ ] )
173
+ angularModule ( INIT_MODULE_NAME , [ ] )
175
174
176
- . constant ( UPGRADE_APP_TYPE_KEY , UpgradeAppType . Static )
175
+ . constant ( UPGRADE_APP_TYPE_KEY , UpgradeAppType . Static )
177
176
178
- . value ( INJECTOR_KEY , this . injector )
177
+ . value ( INJECTOR_KEY , this . injector )
179
178
180
- . factory (
181
- LAZY_MODULE_REF ,
182
- [ INJECTOR_KEY , ( injector : Injector ) => ( { injector} as LazyModuleRef ) ] )
179
+ . factory (
180
+ LAZY_MODULE_REF , [ INJECTOR_KEY , ( injector : Injector ) => ( { injector} as LazyModuleRef ) ] )
183
181
184
- . config ( [
185
- $PROVIDE , $INJECTOR ,
186
- ( $provide : IProvideService , $injector : IInjectorService ) => {
187
- if ( $injector . has ( $$TESTABILITY ) ) {
188
- $provide . decorator ( $$TESTABILITY , [
189
- $DELEGATE ,
190
- ( testabilityDelegate : ITestabilityService ) => {
191
- const originalWhenStable : Function = testabilityDelegate . whenStable ;
192
- const injector = this . injector ;
193
- // Cannot use arrow function below because we need the context
194
- const newWhenStable = function ( callback : Function ) {
195
- originalWhenStable . call ( testabilityDelegate , function ( ) {
196
- const ng2Testability : Testability = injector . get ( Testability ) ;
197
- if ( ng2Testability . isStable ( ) ) {
198
- callback ( ) ;
199
- } else {
200
- ng2Testability . whenStable (
201
- newWhenStable . bind ( testabilityDelegate , callback ) ) ;
202
- }
203
- } ) ;
204
- } ;
182
+ . config ( [
183
+ $PROVIDE , $INJECTOR ,
184
+ ( $provide : IProvideService , $injector : IInjectorService ) => {
185
+ if ( $injector . has ( $$TESTABILITY ) ) {
186
+ $provide . decorator ( $$TESTABILITY , [
187
+ $DELEGATE ,
188
+ ( testabilityDelegate : ITestabilityService ) => {
189
+ const originalWhenStable : Function = testabilityDelegate . whenStable ;
190
+ const injector = this . injector ;
191
+ // Cannot use arrow function below because we need the context
192
+ const newWhenStable = function ( callback : Function ) {
193
+ originalWhenStable . call ( testabilityDelegate , function ( ) {
194
+ const ng2Testability : Testability = injector . get ( Testability ) ;
195
+ if ( ng2Testability . isStable ( ) ) {
196
+ callback ( ) ;
197
+ } else {
198
+ ng2Testability . whenStable (
199
+ newWhenStable . bind ( testabilityDelegate , callback ) ) ;
200
+ }
201
+ } ) ;
202
+ } ;
205
203
206
- testabilityDelegate . whenStable = newWhenStable ;
207
- return testabilityDelegate ;
208
- }
209
- ] ) ;
204
+ testabilityDelegate . whenStable = newWhenStable ;
205
+ return testabilityDelegate ;
210
206
}
207
+ ] ) ;
208
+ }
211
209
212
- if ( $injector . has ( $INTERVAL ) ) {
213
- $provide . decorator ( $INTERVAL , [
214
- $DELEGATE ,
215
- ( intervalDelegate : IIntervalService ) => {
216
- // Wrap the $interval service so that setInterval is called outside NgZone,
217
- // but the callback is still invoked within it. This is so that $interval
218
- // won't block stability, which preserves the behavior from AngularJS.
219
- let wrappedInterval =
220
- ( fn : Function , delay : number , count ?: number , invokeApply ?: boolean ,
221
- ...pass : any [ ] ) => {
222
- return this . ngZone . runOutsideAngular ( ( ) => {
223
- return intervalDelegate ( ( ...args : any [ ] ) => {
224
- // Run callback in the next VM turn - $interval calls
225
- // $rootScope.$apply, and running the callback in NgZone will
226
- // cause a '$digest already in progress' error if it's in the
227
- // same vm turn.
228
- setTimeout ( ( ) => {
229
- this . ngZone . run ( ( ) => fn ( ...args ) ) ;
230
- } ) ;
231
- } , delay , count , invokeApply , ...pass ) ;
210
+ if ( $injector . has ( $INTERVAL ) ) {
211
+ $provide . decorator ( $INTERVAL , [
212
+ $DELEGATE ,
213
+ ( intervalDelegate : IIntervalService ) => {
214
+ // Wrap the $interval service so that setInterval is called outside NgZone,
215
+ // but the callback is still invoked within it. This is so that $interval
216
+ // won't block stability, which preserves the behavior from AngularJS.
217
+ let wrappedInterval =
218
+ ( fn : Function , delay : number , count ?: number , invokeApply ?: boolean ,
219
+ ...pass : any [ ] ) => {
220
+ return this . ngZone . runOutsideAngular ( ( ) => {
221
+ return intervalDelegate ( ( ...args : any [ ] ) => {
222
+ // Run callback in the next VM turn - $interval calls
223
+ // $rootScope.$apply, and running the callback in NgZone will
224
+ // cause a '$digest already in progress' error if it's in the
225
+ // same vm turn.
226
+ setTimeout ( ( ) => {
227
+ this . ngZone . run ( ( ) => fn ( ...args ) ) ;
232
228
} ) ;
233
- } ;
229
+ } , delay , count , invokeApply , ...pass ) ;
230
+ } ) ;
231
+ } ;
234
232
235
- ( wrappedInterval as any ) [ 'cancel' ] = intervalDelegate . cancel ;
236
- return wrappedInterval ;
237
- }
238
- ] ) ;
233
+ ( wrappedInterval as any ) [ 'cancel' ] = intervalDelegate . cancel ;
234
+ return wrappedInterval ;
239
235
}
240
- }
241
- ] )
236
+ ] ) ;
237
+ }
238
+ }
239
+ ] )
242
240
243
- . run ( [
244
- $INJECTOR ,
245
- ( $injector : IInjectorService ) => {
246
- this . $injector = $injector ;
241
+ . run ( [
242
+ $INJECTOR ,
243
+ ( $injector : IInjectorService ) => {
244
+ this . $injector = $injector ;
247
245
248
- // Initialize the ng1 $injector provider
249
- setTempInjectorRef ( $injector ) ;
250
- this . injector . get ( $INJECTOR ) ;
246
+ // Initialize the ng1 $injector provider
247
+ setTempInjectorRef ( $injector ) ;
248
+ this . injector . get ( $INJECTOR ) ;
251
249
252
- // Put the injector on the DOM, so that it can be "required"
253
- angularElement ( element ) . data ! ( controllerKey ( INJECTOR_KEY ) , this . injector ) ;
250
+ // Put the injector on the DOM, so that it can be "required"
251
+ angularElement ( element ) . data ! ( controllerKey ( INJECTOR_KEY ) , this . injector ) ;
254
252
255
- // Wire up the ng1 rootScope to run a digest cycle whenever the zone settles
256
- // We need to do this in the next tick so that we don't prevent the bootup
257
- // stabilizing
258
- setTimeout ( ( ) => {
259
- const $rootScope = $injector . get ( '$rootScope' ) ;
260
- const subscription = this . ngZone . onMicrotaskEmpty . subscribe ( ( ) => {
261
- if ( $rootScope . $$phase ) {
262
- if ( isDevMode ( ) ) {
263
- console . warn (
264
- 'A digest was triggered while one was already in progress. This may mean that something is triggering digests outside the Angular zone.' ) ;
265
- }
253
+ // Wire up the ng1 rootScope to run a digest cycle whenever the zone settles
254
+ // We need to do this in the next tick so that we don't prevent the bootup stabilizing
255
+ setTimeout ( ( ) => {
256
+ const $rootScope = $injector . get ( '$rootScope' ) ;
257
+ const subscription = this . ngZone . onMicrotaskEmpty . subscribe ( ( ) => {
258
+ if ( $rootScope . $$phase ) {
259
+ if ( isDevMode ( ) ) {
260
+ console . warn (
261
+ 'A digest was triggered while one was already in progress. This may mean that something is triggering digests outside the Angular zone.' ) ;
262
+ }
266
263
267
- return $rootScope . $evalAsync ( ) ;
268
- }
264
+ return $rootScope . $evalAsync ( ) ;
265
+ }
269
266
270
- return $rootScope . $digest ( ) ;
271
- } ) ;
272
- $rootScope . $on ( '$destroy' , ( ) => {
273
- subscription . unsubscribe ( ) ;
274
- } ) ;
275
- } , 0 ) ;
276
- }
277
- ] ) ;
267
+ return $rootScope . $digest ( ) ;
268
+ } ) ;
269
+ $rootScope . $on ( '$destroy' , ( ) => {
270
+ subscription . unsubscribe ( ) ;
271
+ } ) ;
272
+ } , 0 ) ;
273
+ }
274
+ ] ) ;
278
275
279
276
const upgradeModule = angularModule ( UPGRADE_MODULE_NAME , [ INIT_MODULE_NAME ] . concat ( modules ) ) ;
280
277
0 commit comments