@angular/upgrade 17.1.0 → 17.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2022/src/common/src/angular1.mjs +5 -5
- package/esm2022/src/common/src/component_info.mjs +1 -1
- package/esm2022/src/common/src/downgrade_component.mjs +17 -14
- package/esm2022/src/common/src/downgrade_component_adapter.mjs +19 -14
- package/esm2022/src/common/src/downgrade_injectable.mjs +1 -1
- package/esm2022/src/common/src/promise_util.mjs +3 -3
- package/esm2022/src/common/src/upgrade_helper.mjs +14 -13
- package/esm2022/src/common/src/util.mjs +16 -14
- package/esm2022/src/common/src/version.mjs +1 -1
- package/esm2022/src/dynamic/src/upgrade_adapter.mjs +31 -22
- package/esm2022/src/dynamic/src/upgrade_ng1_adapter.mjs +20 -17
- package/esm2022/static/public_api.mjs +2 -2
- package/esm2022/static/src/angular1_providers.mjs +2 -2
- package/esm2022/static/src/downgrade_module.mjs +10 -8
- package/esm2022/static/src/upgrade_component.mjs +15 -14
- package/esm2022/static/src/upgrade_module.mjs +16 -13
- package/esm2022/static/src/util.mjs +2 -2
- package/esm2022/static/testing/src/create_angular_testing_module.mjs +7 -6
- package/esm2022/static/testing/src/create_angularjs_testing_module.mjs +6 -6
- package/fesm2022/static/testing.mjs +12 -11
- package/fesm2022/static/testing.mjs.map +1 -1
- package/fesm2022/static.mjs +99 -83
- package/fesm2022/static.mjs.map +1 -1
- package/fesm2022/upgrade.mjs +107 -84
- package/fesm2022/upgrade.mjs.map +1 -1
- package/index.d.ts +1 -1
- package/package.json +5 -5
- package/static/index.d.ts +1 -1
- package/static/testing/index.d.ts +1 -1
package/fesm2022/upgrade.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v17.1.
|
|
2
|
+
* @license Angular v17.1.2
|
|
3
3
|
* (c) 2010-2022 Google LLC. https://angular.io/
|
|
4
4
|
* License: MIT
|
|
5
5
|
*/
|
|
@@ -17,7 +17,7 @@ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
|
|
17
17
|
/**
|
|
18
18
|
* @publicApi
|
|
19
19
|
*/
|
|
20
|
-
const VERSION = new Version('17.1.
|
|
20
|
+
const VERSION = new Version('17.1.2');
|
|
21
21
|
|
|
22
22
|
function noNg() {
|
|
23
23
|
throw new Error('AngularJS v1.x is not loaded!');
|
|
@@ -31,7 +31,7 @@ let angular = {
|
|
|
31
31
|
injector: noNg,
|
|
32
32
|
version: undefined,
|
|
33
33
|
resumeBootstrap: noNg,
|
|
34
|
-
getTestability: noNg
|
|
34
|
+
getTestability: noNg,
|
|
35
35
|
};
|
|
36
36
|
try {
|
|
37
37
|
if (window.hasOwnProperty('angular')) {
|
|
@@ -79,11 +79,11 @@ const bootstrap = (e, modules, config) => angular.bootstrap(e, modules, config);
|
|
|
79
79
|
// Do not declare as `module` to avoid webpack bug
|
|
80
80
|
// (see https://github.com/angular/angular/issues/30050).
|
|
81
81
|
const module_ = (prefix, dependencies) => angular.module(prefix, dependencies);
|
|
82
|
-
const element = (e => angular.element(e));
|
|
83
|
-
element.cleanData = nodes => angular.element.cleanData(nodes);
|
|
82
|
+
const element = ((e) => angular.element(e));
|
|
83
|
+
element.cleanData = (nodes) => angular.element.cleanData(nodes);
|
|
84
84
|
const injector = (modules, strictDi) => angular.injector(modules, strictDi);
|
|
85
85
|
const resumeBootstrap = () => angular.resumeBootstrap();
|
|
86
|
-
const getTestability = e => angular.getTestability(e);
|
|
86
|
+
const getTestability = (e) => angular.getTestability(e);
|
|
87
87
|
|
|
88
88
|
const $COMPILE = '$compile';
|
|
89
89
|
const $CONTROLLER = '$controller';
|
|
@@ -175,7 +175,8 @@ function destroyApp($injector) {
|
|
|
175
175
|
cleanData($rootElement[0]);
|
|
176
176
|
}
|
|
177
177
|
function directiveNormalize(name) {
|
|
178
|
-
return name
|
|
178
|
+
return name
|
|
179
|
+
.replace(DIRECTIVE_PREFIX_REGEXP, '')
|
|
179
180
|
.replace(DIRECTIVE_SPECIAL_CHARS_REGEXP, (_, letter) => letter.toUpperCase());
|
|
180
181
|
}
|
|
181
182
|
function getTypeName(type) {
|
|
@@ -183,12 +184,14 @@ function getTypeName(type) {
|
|
|
183
184
|
return type.overriddenName || type.name || type.toString().split('\n')[0];
|
|
184
185
|
}
|
|
185
186
|
function getDowngradedModuleCount($injector) {
|
|
186
|
-
return $injector.has(DOWNGRADED_MODULE_COUNT_KEY)
|
|
187
|
-
|
|
187
|
+
return $injector.has(DOWNGRADED_MODULE_COUNT_KEY)
|
|
188
|
+
? $injector.get(DOWNGRADED_MODULE_COUNT_KEY)
|
|
189
|
+
: 0;
|
|
188
190
|
}
|
|
189
191
|
function getUpgradeAppType($injector) {
|
|
190
|
-
return $injector.has(UPGRADE_APP_TYPE_KEY)
|
|
191
|
-
|
|
192
|
+
return $injector.has(UPGRADE_APP_TYPE_KEY)
|
|
193
|
+
? $injector.get(UPGRADE_APP_TYPE_KEY)
|
|
194
|
+
: 0 /* UpgradeAppType.None */;
|
|
192
195
|
}
|
|
193
196
|
function isFunction(value) {
|
|
194
197
|
return typeof value === 'function';
|
|
@@ -209,15 +212,15 @@ function validateInjectionKey($injector, downgradedModule, injectionKey, attempt
|
|
|
209
212
|
case 2 /* UpgradeAppType.Static */:
|
|
210
213
|
if (downgradedModule) {
|
|
211
214
|
throw new Error(`Error while ${attemptedAction}: 'downgradedModule' unexpectedly specified.\n` +
|
|
212
|
-
|
|
213
|
-
|
|
215
|
+
"You should not specify a value for 'downgradedModule', unless you are downgrading " +
|
|
216
|
+
"more than one Angular module (via 'downgradeModule()').");
|
|
214
217
|
}
|
|
215
218
|
break;
|
|
216
219
|
case 3 /* UpgradeAppType.Lite */:
|
|
217
|
-
if (!downgradedModule &&
|
|
220
|
+
if (!downgradedModule && downgradedModuleCount >= 2) {
|
|
218
221
|
throw new Error(`Error while ${attemptedAction}: 'downgradedModule' not specified.\n` +
|
|
219
222
|
'This application contains more than one downgraded Angular module, thus you need to ' +
|
|
220
|
-
|
|
223
|
+
"always specify 'downgradedModule' when downgrading components and injectables.");
|
|
221
224
|
}
|
|
222
225
|
if (!$injector.has(injectionKey)) {
|
|
223
226
|
throw new Error(`Error while ${attemptedAction}: Unable to find the specified downgraded module.\n` +
|
|
@@ -245,8 +248,7 @@ class Deferred {
|
|
|
245
248
|
* compatibility.
|
|
246
249
|
*/
|
|
247
250
|
function supportsNgModel(component) {
|
|
248
|
-
return typeof component.writeValue === 'function' &&
|
|
249
|
-
typeof component.registerOnChange === 'function';
|
|
251
|
+
return (typeof component.writeValue === 'function' && typeof component.registerOnChange === 'function');
|
|
250
252
|
}
|
|
251
253
|
/**
|
|
252
254
|
* Glue the AngularJS `NgModelController` (if it exists) to the component
|
|
@@ -271,7 +273,7 @@ function strictEquals(val1, val2) {
|
|
|
271
273
|
}
|
|
272
274
|
|
|
273
275
|
const INITIAL_VALUE$1 = {
|
|
274
|
-
__UNINITIALIZED__: true
|
|
276
|
+
__UNINITIALIZED__: true,
|
|
275
277
|
};
|
|
276
278
|
class DowngradeComponentAdapter {
|
|
277
279
|
constructor(element, attrs, scope, ngModel, parentInjector, $compile, $parse, componentFactory, wrapCallback) {
|
|
@@ -292,9 +294,9 @@ class DowngradeComponentAdapter {
|
|
|
292
294
|
compileContents() {
|
|
293
295
|
const compiledProjectableNodes = [];
|
|
294
296
|
const projectableNodes = this.groupProjectableNodes();
|
|
295
|
-
const linkFns = projectableNodes.map(nodes => this.$compile(nodes));
|
|
297
|
+
const linkFns = projectableNodes.map((nodes) => this.$compile(nodes));
|
|
296
298
|
this.element.empty();
|
|
297
|
-
linkFns.forEach(linkFn => {
|
|
299
|
+
linkFns.forEach((linkFn) => {
|
|
298
300
|
linkFn(this.scope, (clone) => {
|
|
299
301
|
compiledProjectableNodes.push(clone);
|
|
300
302
|
this.element.append(clone);
|
|
@@ -311,7 +313,11 @@ class DowngradeComponentAdapter {
|
|
|
311
313
|
}
|
|
312
314
|
createComponent(projectableNodes) {
|
|
313
315
|
const providers = [{ provide: $SCOPE, useValue: this.componentScope }];
|
|
314
|
-
const childInjector = Injector.create({
|
|
316
|
+
const childInjector = Injector.create({
|
|
317
|
+
providers: providers,
|
|
318
|
+
parent: this.parentInjector,
|
|
319
|
+
name: 'DowngradeComponentAdapter',
|
|
320
|
+
});
|
|
315
321
|
const componentRef = this.componentFactory.create(childInjector, projectableNodes, this.element[0]);
|
|
316
322
|
const viewChangeDetector = componentRef.injector.get(ChangeDetectorRef);
|
|
317
323
|
const changeDetector = componentRef.changeDetectorRef;
|
|
@@ -321,7 +327,8 @@ class DowngradeComponentAdapter {
|
|
|
321
327
|
// testability hook.
|
|
322
328
|
const testability = componentRef.injector.get(Testability, null);
|
|
323
329
|
if (testability) {
|
|
324
|
-
componentRef.injector
|
|
330
|
+
componentRef.injector
|
|
331
|
+
.get(TestabilityRegistry)
|
|
325
332
|
.registerApplication(componentRef.location.nativeElement, testability);
|
|
326
333
|
}
|
|
327
334
|
hookupNgModel(this.ngModel, componentRef.instance);
|
|
@@ -334,7 +341,7 @@ class DowngradeComponentAdapter {
|
|
|
334
341
|
const inputBinding = new PropertyBinding(input.propName, input.templateName);
|
|
335
342
|
let expr = null;
|
|
336
343
|
if (attrs.hasOwnProperty(inputBinding.attr)) {
|
|
337
|
-
const observeFn = (prop => {
|
|
344
|
+
const observeFn = ((prop) => {
|
|
338
345
|
let prevValue = INITIAL_VALUE$1;
|
|
339
346
|
return (currValue) => {
|
|
340
347
|
// Initially, both `$observe()` and `$watch()` will call this function.
|
|
@@ -437,8 +444,9 @@ class DowngradeComponentAdapter {
|
|
|
437
444
|
const emitter = componentRef.instance[output.prop];
|
|
438
445
|
if (emitter) {
|
|
439
446
|
const subscription = emitter.subscribe({
|
|
440
|
-
next: isAssignment
|
|
441
|
-
(v) =>
|
|
447
|
+
next: isAssignment
|
|
448
|
+
? (v) => setter(this.scope, v)
|
|
449
|
+
: (v) => getter(this.scope, { '$event': v }),
|
|
442
450
|
});
|
|
443
451
|
componentRef.onDestroy(() => subscription.unsubscribe());
|
|
444
452
|
}
|
|
@@ -532,10 +540,9 @@ function findMatchingNgContentIndex(element, ngContentSelectors) {
|
|
|
532
540
|
function matchesSelector(el, selector) {
|
|
533
541
|
const elProto = Element.prototype;
|
|
534
542
|
return el.nodeType === Node.ELEMENT_NODE
|
|
535
|
-
// matches is supported by all browsers from 2014 onwards except non-chromium edge
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
false;
|
|
543
|
+
? // matches is supported by all browsers from 2014 onwards except non-chromium edge
|
|
544
|
+
(elProto.matches ?? elProto.msMatchesSelector).call(el, selector)
|
|
545
|
+
: false;
|
|
539
546
|
}
|
|
540
547
|
|
|
541
548
|
function isThenable(obj) {
|
|
@@ -560,7 +567,7 @@ class SyncPromise {
|
|
|
560
567
|
};
|
|
561
568
|
valuesOrPromises.forEach((p, idx) => {
|
|
562
569
|
if (isThenable(p)) {
|
|
563
|
-
p.then(v => resolve(idx, v));
|
|
570
|
+
p.then((v) => resolve(idx, v));
|
|
564
571
|
}
|
|
565
572
|
else {
|
|
566
573
|
resolve(idx, p);
|
|
@@ -575,7 +582,7 @@ class SyncPromise {
|
|
|
575
582
|
this.value = value;
|
|
576
583
|
this.resolved = true;
|
|
577
584
|
// Run the queued callbacks.
|
|
578
|
-
this.callbacks.forEach(callback => callback(value));
|
|
585
|
+
this.callbacks.forEach((callback) => callback(value));
|
|
579
586
|
this.callbacks.length = 0;
|
|
580
587
|
}
|
|
581
588
|
then(callback) {
|
|
@@ -648,10 +655,12 @@ function downgradeComponent(info) {
|
|
|
648
655
|
// inside the Angular zone (except if explicitly escaped, in which case we shouldn't
|
|
649
656
|
// force it back in).
|
|
650
657
|
const isNgUpgradeLite = getUpgradeAppType($injector) === 3 /* UpgradeAppType.Lite */;
|
|
651
|
-
const wrapCallback = !isNgUpgradeLite
|
|
658
|
+
const wrapCallback = !isNgUpgradeLite
|
|
659
|
+
? (cb) => cb
|
|
660
|
+
: (cb) => () => (NgZone.isInAngularZone() ? cb() : ngZone.run(cb));
|
|
652
661
|
let ngZone;
|
|
653
662
|
// When downgrading multiple modules, special handling is needed wrt injectors.
|
|
654
|
-
const hasMultipleDowngradedModules = isNgUpgradeLite &&
|
|
663
|
+
const hasMultipleDowngradedModules = isNgUpgradeLite && getDowngradedModuleCount($injector) > 1;
|
|
655
664
|
return {
|
|
656
665
|
restrict: 'E',
|
|
657
666
|
terminal: true,
|
|
@@ -734,20 +743,21 @@ function downgradeComponent(info) {
|
|
|
734
743
|
scope.$evalAsync(() => { });
|
|
735
744
|
}
|
|
736
745
|
};
|
|
737
|
-
const downgradeFn = !isNgUpgradeLite
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
746
|
+
const downgradeFn = !isNgUpgradeLite
|
|
747
|
+
? doDowngrade
|
|
748
|
+
: (pInjector, mInjector) => {
|
|
749
|
+
if (!ngZone) {
|
|
750
|
+
ngZone = pInjector.get(NgZone);
|
|
751
|
+
}
|
|
752
|
+
wrapCallback(() => doDowngrade(pInjector, mInjector))();
|
|
753
|
+
};
|
|
743
754
|
// NOTE:
|
|
744
755
|
// Not using `ParentInjectorPromise.all()` (which is inherited from `SyncPromise`), because
|
|
745
756
|
// Closure Compiler (or some related tool) complains:
|
|
746
757
|
// `TypeError: ...$src$downgrade_component_ParentInjectorPromise.all is not a function`
|
|
747
|
-
SyncPromise.all([finalParentInjector, finalModuleInjector])
|
|
748
|
-
.then(([pInjector, mInjector]) => downgradeFn(pInjector, mInjector));
|
|
758
|
+
SyncPromise.all([finalParentInjector, finalModuleInjector]).then(([pInjector, mInjector]) => downgradeFn(pInjector, mInjector));
|
|
749
759
|
ranAsync = true;
|
|
750
|
-
}
|
|
760
|
+
},
|
|
751
761
|
};
|
|
752
762
|
};
|
|
753
763
|
// bracket-notation because of closure - see #14441
|
|
@@ -923,8 +933,7 @@ class UpgradeHelper {
|
|
|
923
933
|
}
|
|
924
934
|
compileTemplate(template) {
|
|
925
935
|
if (template === undefined) {
|
|
926
|
-
template =
|
|
927
|
-
UpgradeHelper.getTemplate(this.$injector, this.directive, false, this.$element);
|
|
936
|
+
template = UpgradeHelper.getTemplate(this.$injector, this.directive, false, this.$element);
|
|
928
937
|
}
|
|
929
938
|
return this.compileHtml(template);
|
|
930
939
|
}
|
|
@@ -954,7 +963,7 @@ class UpgradeHelper {
|
|
|
954
963
|
const slotMap = Object.create(null);
|
|
955
964
|
const filledSlots = Object.create(null);
|
|
956
965
|
// Parse the element selectors.
|
|
957
|
-
Object.keys(transclude).forEach(slotName => {
|
|
966
|
+
Object.keys(transclude).forEach((slotName) => {
|
|
958
967
|
let selector = transclude[slotName];
|
|
959
968
|
const optional = selector.charAt(0) === '?';
|
|
960
969
|
selector = optional ? selector.substring(1) : selector;
|
|
@@ -963,7 +972,7 @@ class UpgradeHelper {
|
|
|
963
972
|
filledSlots[slotName] = optional; // Consider optional slots as filled.
|
|
964
973
|
});
|
|
965
974
|
// Add the matching elements into their slot.
|
|
966
|
-
contentChildNodes.forEach(node => {
|
|
975
|
+
contentChildNodes.forEach((node) => {
|
|
967
976
|
const slotName = slotMap[directiveNormalize(node.nodeName.toLowerCase())];
|
|
968
977
|
if (slotName) {
|
|
969
978
|
filledSlots[slotName] = true;
|
|
@@ -975,12 +984,14 @@ class UpgradeHelper {
|
|
|
975
984
|
}
|
|
976
985
|
});
|
|
977
986
|
// Check for required slots that were not filled.
|
|
978
|
-
Object.keys(filledSlots).forEach(slotName => {
|
|
987
|
+
Object.keys(filledSlots).forEach((slotName) => {
|
|
979
988
|
if (!filledSlots[slotName]) {
|
|
980
989
|
throw new Error(`Required transclusion slot '${slotName}' on directive: ${this.name}`);
|
|
981
990
|
}
|
|
982
991
|
});
|
|
983
|
-
Object.keys(slots)
|
|
992
|
+
Object.keys(slots)
|
|
993
|
+
.filter((slotName) => slots[slotName])
|
|
994
|
+
.forEach((slotName) => {
|
|
984
995
|
const nodes = slots[slotName];
|
|
985
996
|
slots[slotName] = (scope, cloneAttach) => {
|
|
986
997
|
return cloneAttach(nodes, scope);
|
|
@@ -999,7 +1010,7 @@ class UpgradeHelper {
|
|
|
999
1010
|
// to empty text nodes (which can only be a result of Angular removing their initial content).
|
|
1000
1011
|
// NOTE: Transcluded text content that starts with whitespace followed by an interpolation
|
|
1001
1012
|
// will still fail to be detected by AngularJS v1.6+
|
|
1002
|
-
$template.forEach(node => {
|
|
1013
|
+
$template.forEach((node) => {
|
|
1003
1014
|
if (node.nodeType === Node.TEXT_NODE && !node.nodeValue) {
|
|
1004
1015
|
node.nodeValue = '\u200C';
|
|
1005
1016
|
}
|
|
@@ -1012,7 +1023,7 @@ class UpgradeHelper {
|
|
|
1012
1023
|
const requiredControllers = this.resolveRequire(directiveRequire);
|
|
1013
1024
|
if (controllerInstance && this.directive.bindToController && isMap(directiveRequire)) {
|
|
1014
1025
|
const requiredControllersMap = requiredControllers;
|
|
1015
|
-
Object.keys(requiredControllersMap).forEach(key => {
|
|
1026
|
+
Object.keys(requiredControllersMap).forEach((key) => {
|
|
1016
1027
|
controllerInstance[key] = requiredControllersMap[key];
|
|
1017
1028
|
});
|
|
1018
1029
|
}
|
|
@@ -1025,7 +1036,7 @@ class UpgradeHelper {
|
|
|
1025
1036
|
extractChildNodes() {
|
|
1026
1037
|
const childNodes = [];
|
|
1027
1038
|
let childNode;
|
|
1028
|
-
while (childNode = this.element.firstChild) {
|
|
1039
|
+
while ((childNode = this.element.firstChild)) {
|
|
1029
1040
|
this.element.removeChild(childNode);
|
|
1030
1041
|
childNodes.push(childNode);
|
|
1031
1042
|
}
|
|
@@ -1049,11 +1060,11 @@ class UpgradeHelper {
|
|
|
1049
1060
|
return null;
|
|
1050
1061
|
}
|
|
1051
1062
|
else if (Array.isArray(require)) {
|
|
1052
|
-
return require.map(req => this.resolveRequire(req));
|
|
1063
|
+
return require.map((req) => this.resolveRequire(req));
|
|
1053
1064
|
}
|
|
1054
1065
|
else if (typeof require === 'object') {
|
|
1055
1066
|
const value = {};
|
|
1056
|
-
Object.keys(require).forEach(key => value[key] = this.resolveRequire(require[key]));
|
|
1067
|
+
Object.keys(require).forEach((key) => (value[key] = this.resolveRequire(require[key])));
|
|
1057
1068
|
return value;
|
|
1058
1069
|
}
|
|
1059
1070
|
else if (typeof require === 'string') {
|
|
@@ -1089,7 +1100,7 @@ function notSupported(name, feature) {
|
|
|
1089
1100
|
|
|
1090
1101
|
const CAMEL_CASE = /([A-Z])/g;
|
|
1091
1102
|
const INITIAL_VALUE = {
|
|
1092
|
-
__UNINITIALIZED__: true
|
|
1103
|
+
__UNINITIALIZED__: true,
|
|
1093
1104
|
};
|
|
1094
1105
|
const NOT_SUPPORTED = 'NOT_SUPPORTED';
|
|
1095
1106
|
function getInputPropertyMapName(name) {
|
|
@@ -1117,7 +1128,12 @@ class UpgradeNg1ComponentAdapterBuilder {
|
|
|
1117
1128
|
}
|
|
1118
1129
|
};
|
|
1119
1130
|
MyClass = __decorate([
|
|
1120
|
-
Directive({
|
|
1131
|
+
Directive({
|
|
1132
|
+
jit: true,
|
|
1133
|
+
selector: selector,
|
|
1134
|
+
inputs: this.inputsRename,
|
|
1135
|
+
outputs: this.outputsRename,
|
|
1136
|
+
}),
|
|
1121
1137
|
__param(0, Inject($SCOPE)),
|
|
1122
1138
|
__metadata("design:paramtypes", [Object, Injector, ElementRef])
|
|
1123
1139
|
], MyClass);
|
|
@@ -1128,9 +1144,9 @@ class UpgradeNg1ComponentAdapterBuilder {
|
|
|
1128
1144
|
if (btcIsObject && Object.keys(this.directive.scope).length) {
|
|
1129
1145
|
throw new Error(`Binding definitions on scope and controller at the same time are not supported.`);
|
|
1130
1146
|
}
|
|
1131
|
-
const context =
|
|
1147
|
+
const context = btcIsObject ? this.directive.bindToController : this.directive.scope;
|
|
1132
1148
|
if (typeof context == 'object') {
|
|
1133
|
-
Object.keys(context).forEach(propName => {
|
|
1149
|
+
Object.keys(context).forEach((propName) => {
|
|
1134
1150
|
const definition = context[propName];
|
|
1135
1151
|
const bindingType = definition.charAt(0);
|
|
1136
1152
|
const bindingOptions = definition.charAt(1);
|
|
@@ -1177,9 +1193,7 @@ class UpgradeNg1ComponentAdapterBuilder {
|
|
|
1177
1193
|
const promises = Object.entries(exportedComponents).map(([name, exportedComponent]) => {
|
|
1178
1194
|
exportedComponent.directive = UpgradeHelper.getDirective($injector, name);
|
|
1179
1195
|
exportedComponent.extractBindings();
|
|
1180
|
-
return Promise
|
|
1181
|
-
.resolve(UpgradeHelper.getTemplate($injector, exportedComponent.directive, true))
|
|
1182
|
-
.then(template => exportedComponent.template = template);
|
|
1196
|
+
return Promise.resolve(UpgradeHelper.getTemplate($injector, exportedComponent.directive, true)).then((template) => (exportedComponent.template = template));
|
|
1183
1197
|
});
|
|
1184
1198
|
return Promise.all(promises);
|
|
1185
1199
|
}
|
|
@@ -1213,9 +1227,9 @@ class UpgradeNg1ComponentAdapter {
|
|
|
1213
1227
|
this[input] = null;
|
|
1214
1228
|
}
|
|
1215
1229
|
for (const output of this.outputs) {
|
|
1216
|
-
const emitter = this[output] = new EventEmitter();
|
|
1230
|
+
const emitter = (this[output] = new EventEmitter());
|
|
1217
1231
|
if (this.propOuts.indexOf(output) === -1) {
|
|
1218
|
-
this.setComponentProperty(output, (emitter => (value) => emitter.emit(value))(emitter));
|
|
1232
|
+
this.setComponentProperty(output, ((emitter) => (value) => emitter.emit(value))(emitter));
|
|
1219
1233
|
}
|
|
1220
1234
|
}
|
|
1221
1235
|
this.checkLastValues.push(...Array(propOuts.length).fill(INITIAL_VALUE));
|
|
@@ -1256,7 +1270,7 @@ class UpgradeNg1ComponentAdapter {
|
|
|
1256
1270
|
}
|
|
1257
1271
|
ngOnChanges(changes) {
|
|
1258
1272
|
const ng1Changes = {};
|
|
1259
|
-
Object.keys(changes).forEach(propertyMapName => {
|
|
1273
|
+
Object.keys(changes).forEach((propertyMapName) => {
|
|
1260
1274
|
const change = changes[propertyMapName];
|
|
1261
1275
|
this.setComponentProperty(propertyMapName, change.currentValue);
|
|
1262
1276
|
ng1Changes[this.propertyMap[propertyMapName]] = change;
|
|
@@ -1275,7 +1289,7 @@ class UpgradeNg1ComponentAdapter {
|
|
|
1275
1289
|
const last = lastValues[i];
|
|
1276
1290
|
if (!strictEquals(last, value)) {
|
|
1277
1291
|
const eventEmitter = this[propOuts[i]];
|
|
1278
|
-
eventEmitter.emit(lastValues[i] = value);
|
|
1292
|
+
eventEmitter.emit((lastValues[i] = value));
|
|
1279
1293
|
}
|
|
1280
1294
|
});
|
|
1281
1295
|
if (this.controllerInstance && isFunction(this.controllerInstance.$doCheck)) {
|
|
@@ -1288,10 +1302,10 @@ class UpgradeNg1ComponentAdapter {
|
|
|
1288
1302
|
setComponentProperty(name, value) {
|
|
1289
1303
|
this.destinationObj[this.propertyMap[name]] = value;
|
|
1290
1304
|
}
|
|
1291
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.
|
|
1292
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.
|
|
1305
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.1.2", ngImport: i0, type: UpgradeNg1ComponentAdapter, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1306
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "17.1.2", type: UpgradeNg1ComponentAdapter, usesOnChanges: true, ngImport: i0 }); }
|
|
1293
1307
|
}
|
|
1294
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.
|
|
1308
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.1.2", ngImport: i0, type: UpgradeNg1ComponentAdapter, decorators: [{
|
|
1295
1309
|
type: Directive
|
|
1296
1310
|
}], ctorParameters: () => [{ type: UpgradeHelper }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }] });
|
|
1297
1311
|
|
|
@@ -1595,7 +1609,7 @@ class UpgradeAdapter {
|
|
|
1595
1609
|
registerForNg1Tests(modules) {
|
|
1596
1610
|
const windowNgMock = window['angular'].mock;
|
|
1597
1611
|
if (!windowNgMock || !windowNgMock.module) {
|
|
1598
|
-
throw new Error(
|
|
1612
|
+
throw new Error("Failed to find 'angular.mock.module'.");
|
|
1599
1613
|
}
|
|
1600
1614
|
const { ng1Module, ng2BootstrapDeferred } = this.declareNg1Module(modules);
|
|
1601
1615
|
windowNgMock.module(ng1Module.name);
|
|
@@ -1715,11 +1729,11 @@ class UpgradeAdapter {
|
|
|
1715
1729
|
* ```
|
|
1716
1730
|
*/
|
|
1717
1731
|
upgradeNg1Provider(name, options) {
|
|
1718
|
-
const token = options && options.asToken || name;
|
|
1732
|
+
const token = (options && options.asToken) || name;
|
|
1719
1733
|
this.upgradedProviders.push({
|
|
1720
1734
|
provide: token,
|
|
1721
1735
|
useFactory: ($injector) => $injector.get(name),
|
|
1722
|
-
deps: [$INJECTOR]
|
|
1736
|
+
deps: [$INJECTOR],
|
|
1723
1737
|
});
|
|
1724
1738
|
}
|
|
1725
1739
|
/**
|
|
@@ -1770,15 +1784,22 @@ class UpgradeAdapter {
|
|
|
1770
1784
|
const upgradeAdapter = this;
|
|
1771
1785
|
const ng1Module = module_(this.idPrefix, modules);
|
|
1772
1786
|
const platformRef = platformBrowserDynamic();
|
|
1773
|
-
const ngZone = new NgZone({
|
|
1787
|
+
const ngZone = new NgZone({
|
|
1788
|
+
enableLongStackTrace: Zone.hasOwnProperty('longStackTraceZoneSpec'),
|
|
1789
|
+
});
|
|
1774
1790
|
const ng2BootstrapDeferred = new Deferred();
|
|
1775
|
-
ng1Module
|
|
1791
|
+
ng1Module
|
|
1792
|
+
.constant(UPGRADE_APP_TYPE_KEY, 1 /* UpgradeAppType.Dynamic */)
|
|
1776
1793
|
.factory(INJECTOR_KEY, () => this.moduleRef.injector.get(Injector))
|
|
1777
|
-
.factory(LAZY_MODULE_REF, [
|
|
1794
|
+
.factory(LAZY_MODULE_REF, [
|
|
1795
|
+
INJECTOR_KEY,
|
|
1796
|
+
(injector) => ({ injector }),
|
|
1797
|
+
])
|
|
1778
1798
|
.constant(NG_ZONE_KEY, ngZone)
|
|
1779
1799
|
.factory(COMPILER_KEY, () => this.moduleRef.injector.get(Compiler))
|
|
1780
1800
|
.config([
|
|
1781
|
-
'$provide',
|
|
1801
|
+
'$provide',
|
|
1802
|
+
'$injector',
|
|
1782
1803
|
(provide, ng1Injector) => {
|
|
1783
1804
|
provide.decorator($ROOT_SCOPE, [
|
|
1784
1805
|
'$delegate',
|
|
@@ -1791,10 +1812,10 @@ class UpgradeAdapter {
|
|
|
1791
1812
|
rootScopePrototype.$apply = (exp) => delayApplyExps.push(exp);
|
|
1792
1813
|
}
|
|
1793
1814
|
else {
|
|
1794
|
-
throw new Error(
|
|
1815
|
+
throw new Error("Failed to find '$apply' on '$rootScope'!");
|
|
1795
1816
|
}
|
|
1796
1817
|
return rootScopeDelegate;
|
|
1797
|
-
}
|
|
1818
|
+
},
|
|
1798
1819
|
]);
|
|
1799
1820
|
if (ng1Injector.has($$TESTABILITY)) {
|
|
1800
1821
|
provide.decorator($$TESTABILITY, [
|
|
@@ -1815,13 +1836,14 @@ class UpgradeAdapter {
|
|
|
1815
1836
|
};
|
|
1816
1837
|
testabilityDelegate.whenStable = newWhenStable;
|
|
1817
1838
|
return testabilityDelegate;
|
|
1818
|
-
}
|
|
1839
|
+
},
|
|
1819
1840
|
]);
|
|
1820
1841
|
}
|
|
1821
|
-
}
|
|
1842
|
+
},
|
|
1822
1843
|
]);
|
|
1823
1844
|
ng1Module.run([
|
|
1824
|
-
'$injector',
|
|
1845
|
+
'$injector',
|
|
1846
|
+
'$rootScope',
|
|
1825
1847
|
(ng1Injector, rootScope) => {
|
|
1826
1848
|
UpgradeNg1ComponentAdapterBuilder.resolve(this.ng1ComponentsToBeUpgraded, ng1Injector)
|
|
1827
1849
|
.then(() => {
|
|
@@ -1836,12 +1858,13 @@ class UpgradeAdapter {
|
|
|
1836
1858
|
providers: [
|
|
1837
1859
|
{ provide: $INJECTOR, useFactory: () => ng1Injector },
|
|
1838
1860
|
{ provide: $COMPILE, useFactory: () => ng1Injector.get($COMPILE) },
|
|
1839
|
-
this.upgradedProviders
|
|
1861
|
+
this.upgradedProviders,
|
|
1840
1862
|
],
|
|
1841
|
-
imports: [resolveForwardRef(this.ng2AppModule)]
|
|
1863
|
+
imports: [resolveForwardRef(this.ng2AppModule)],
|
|
1842
1864
|
})
|
|
1843
1865
|
], DynamicNgUpgradeModule);
|
|
1844
|
-
platformRef
|
|
1866
|
+
platformRef
|
|
1867
|
+
.bootstrapModule(DynamicNgUpgradeModule, [this.compilerOptions, { ngZone }])
|
|
1845
1868
|
.then((ref) => {
|
|
1846
1869
|
this.moduleRef = ref;
|
|
1847
1870
|
ngZone.run(() => {
|
|
@@ -1865,7 +1888,7 @@ class UpgradeAdapter {
|
|
|
1865
1888
|
return rootScope.$evalAsync(() => { });
|
|
1866
1889
|
}
|
|
1867
1890
|
return rootScope.$digest();
|
|
1868
|
-
}
|
|
1891
|
+
},
|
|
1869
1892
|
});
|
|
1870
1893
|
rootScope.$on('$destroy', () => {
|
|
1871
1894
|
subscription.unsubscribe();
|
|
@@ -1879,7 +1902,7 @@ class UpgradeAdapter {
|
|
|
1879
1902
|
});
|
|
1880
1903
|
})
|
|
1881
1904
|
.catch((e) => ng2BootstrapDeferred.reject(e));
|
|
1882
|
-
}
|
|
1905
|
+
},
|
|
1883
1906
|
]);
|
|
1884
1907
|
return { ng1Module, ng2BootstrapDeferred, ngZone };
|
|
1885
1908
|
}
|