8000 refactor(upgrade): remove unused variables (#40045) · angular/angular@61376d5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 61376d5

Browse files
gkalpakalxhub
authored andcommitted
refactor(upgrade): remove unused variables (#40045)
This commit removes a couple of unused variables. PR Close #40045
1 parent 76e3de2 commit 61376d5

File tree

2 files changed

+87
-91
lines changed

2 files changed

+87
-91
lines changed

packages/upgrade/src/dynamic/src/upgrade_adapter.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,6 @@ export class UpgradeAdapter {
505505
const delayApplyExps: Function[] = [];
506506
let original$applyFn: Function;
507507
let rootScopePrototype: any;
508-
let rootScope: IRootScopeService;
509508
const upgradeAdapter = this;
510509
const ng1Module = this.ng1Module = angularModule(this.idPrefix, modules);
511510
const platformRef = platformBrowserDynamic();
@@ -533,7 +532,7 @@ export class UpgradeAdapter {
533532
} else {
534533
throw new Error('Failed to find \'$apply\' on \'$rootScope\'!');
535534
}
536-
return rootScope = rootScopeDelegate;
535+
return rootScopeDelegate;
537536
}
538537
]);
539538
if (ng1Injector.has($$TESTABILITY)) {

packages/upgrade/static/src/upgrade_module.ts

Lines changed: 86 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -170,111 +170,108 @@ export class UpgradeModule {
170170
const INIT_MODULE_NAME = UPGRADE_MODULE_NAME + '.init';
171171

172172
// Create an ng1 module to bootstrap
173-
const initModule =
174-
angularModule(INIT_MODULE_NAME, [])
173+
angularModule(INIT_MODULE_NAME, [])
175174

176-
.constant(UPGRADE_APP_TYPE_KEY, UpgradeAppType.Static)
175+
.constant(UPGRADE_APP_TYPE_KEY, UpgradeAppType.Static)
177176

178-
.value(INJECTOR_KEY, this.injector)
177+
.value(INJECTOR_KEY, this.injector)
179178

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)])
183181

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+
};
205203

206-
testabilityDelegate.whenStable = newWhenStable;
207-
return testabilityDelegate;
208-
}
209-
]);
204+
testabilityDelegate.whenStable = newWhenStable;
205+
return testabilityDelegate;
210206
}
207+
]);
208+
}
211209

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));
232228
});
233-
};
229+
}, delay, count, invokeApply, ...pass);
230+
});
231+
};
234232

235-
(wrappedInterval as any)['cancel'] = intervalDelegate.cancel;
236-
return wrappedInterval;
237-
}
238-
]);
233+
(wrappedInterval as any)['cancel'] = intervalDelegate.cancel;
234+
return wrappedInterval;
239235
}
240-
}
241-
])
236+
]);
237+
}
238+
}
239+
])
242240

243-
.run([
244-
$INJECTOR,
245-
($injector: IInjectorService) => {
246-
this.$injector = $injector;
241+
.run([
242+
$INJECTOR,
243+
($injector: IInjectorService) => {
244+
this.$injector = $injector;
247245

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);
251249

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);
254252

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+
}
266263

267-
return $rootScope.$evalAsync();
268-
}
264+
return $rootScope.$evalAsync();
265+
}
269266

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+
]);
278275

279276
const upgradeModule = angularModule(UPGRADE_MODULE_NAME, [INIT_MODULE_NAME].concat(modules));
280277

0 commit comments

Comments
 (0)
0