@angular/upgrade 18.2.1 → 18.2.3
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/security/trusted_types.mjs +48 -0
- package/esm2022/src/common/src/security/trusted_types_defs.mjs +9 -0
- package/esm2022/src/common/src/upgrade_helper.mjs +5 -4
- package/esm2022/src/common/src/version.mjs +1 -1
- package/esm2022/src/dynamic/src/upgrade_ng1_adapter.mjs +6 -5
- package/esm2022/static/src/upgrade_component.mjs +3 -3
- package/esm2022/static/src/upgrade_module.mjs +4 -4
- package/esm2022/static/testing/src/create_angular_testing_module.mjs +4 -4
- package/fesm2022/static/testing.mjs +5 -5
- package/fesm2022/static.mjs +53 -12
- package/fesm2022/static.mjs.map +1 -1
- package/fesm2022/upgrade.mjs +50 -9
- package/fesm2022/upgrade.mjs.map +1 -1
- package/index.d.ts +1 -1
- package/package.json +5 -5
- package/static/index.d.ts +27 -3
- package/static/testing/index.d.ts +1 -1
package/fesm2022/upgrade.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license Angular v18.2.
|
|
2
|
+
* @license Angular v18.2.3
|
|
3
3
|
* (c) 2010-2024 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('18.2.
|
|
20
|
+
const VERSION = new Version('18.2.3');
|
|
21
21
|
|
|
22
22
|
function noNg() {
|
|
23
23
|
throw new Error('AngularJS v1.x is not loaded!');
|
|
@@ -864,6 +864,47 @@ function downgradeInjectable(token, downgradedModule = '') {
|
|
|
864
864
|
return factory;
|
|
865
865
|
}
|
|
866
866
|
|
|
867
|
+
/**
|
|
868
|
+
* The Trusted Types policy, or null if Trusted Types are not
|
|
869
|
+
* enabled/supported, or undefined if the policy has not been created yet.
|
|
870
|
+
*/
|
|
871
|
+
let policy;
|
|
872
|
+
/**
|
|
873
|
+
* Returns the Trusted Types policy, or null if Trusted Types are not
|
|
874
|
+
* enabled/supported. The first call to this function will create the policy.
|
|
875
|
+
*/
|
|
876
|
+
function getPolicy() {
|
|
877
|
+
if (policy === undefined) {
|
|
878
|
+
policy = null;
|
|
879
|
+
const windowWithTrustedTypes = window;
|
|
880
|
+
if (windowWithTrustedTypes.trustedTypes) {
|
|
881
|
+
try {
|
|
882
|
+
policy = windowWithTrustedTypes.trustedTypes.createPolicy('angular#unsafe-upgrade', {
|
|
883
|
+
createHTML: (s) => s,
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
catch {
|
|
887
|
+
// trustedTypes.createPolicy throws if called with a name that is
|
|
888
|
+
// already registered, even in report-only mode. Until the API changes,
|
|
889
|
+
// catch the error not to break the applications functionally. In such
|
|
890
|
+
// cases, the code will fall back to using strings.
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
}
|
|
894
|
+
return policy;
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Unsafely promote a legacy AngularJS template to a TrustedHTML, falling back
|
|
898
|
+
* to strings when Trusted Types are not available.
|
|
899
|
+
* @security This is a security-sensitive function; any use of this function
|
|
900
|
+
* must go through security review. In particular, the template string should
|
|
901
|
+
* always be under full control of the application author, as untrusted input
|
|
902
|
+
* can cause an XSS vulnerability.
|
|
903
|
+
*/
|
|
904
|
+
function trustedHTMLFromLegacyTemplate(html) {
|
|
905
|
+
return getPolicy()?.createHTML(html) || html;
|
|
906
|
+
}
|
|
907
|
+
|
|
867
908
|
// Constants
|
|
868
909
|
const REQUIRE_PREFIX_RE = /^(\^\^?)?(\?)?(\^\^?)?/;
|
|
869
910
|
// Classes
|
|
@@ -895,14 +936,14 @@ class UpgradeHelper {
|
|
|
895
936
|
}
|
|
896
937
|
static getTemplate($injector, directive, fetchRemoteTemplate = false, $element) {
|
|
897
938
|
if (directive.template !== undefined) {
|
|
898
|
-
return getOrCall(directive.template, $element);
|
|
939
|
+
return trustedHTMLFromLegacyTemplate(getOrCall(directive.template, $element));
|
|
899
940
|
}
|
|
900
941
|
else if (directive.templateUrl) {
|
|
901
942
|
const $templateCache = $injector.get($TEMPLATE_CACHE);
|
|
902
943
|
const url = getOrCall(directive.templateUrl, $element);
|
|
903
944
|
const template = $templateCache.get(url);
|
|
904
945
|
if (template !== undefined) {
|
|
905
|
-
return template;
|
|
946
|
+
return trustedHTMLFromLegacyTemplate(template);
|
|
906
947
|
}
|
|
907
948
|
else if (!fetchRemoteTemplate) {
|
|
908
949
|
throw new Error('loading directive templates asynchronously is not supported');
|
|
@@ -911,7 +952,7 @@ class UpgradeHelper {
|
|
|
911
952
|
const $httpBackend = $injector.get($HTTP_BACKEND);
|
|
912
953
|
$httpBackend('GET', url, null, (status, response) => {
|
|
913
954
|
if (status === 200) {
|
|
914
|
-
resolve($templateCache.put(url, response));
|
|
955
|
+
resolve(trustedHTMLFromLegacyTemplate($templateCache.put(url, response)));
|
|
915
956
|
}
|
|
916
957
|
else {
|
|
917
958
|
reject(`GET component template from '${url}' returned '${status}: ${response}'`);
|
|
@@ -1241,7 +1282,7 @@ class UpgradeNg1ComponentAdapter {
|
|
|
1241
1282
|
ngOnInit() {
|
|
1242
1283
|
// Collect contents, insert and compile template
|
|
1243
1284
|
const attachChildNodes = this.helper.prepareTransclusion();
|
|
1244
|
-
const linkFn = this.helper.compileTemplate(this.template);
|
|
1285
|
+
const linkFn = this.helper.compileTemplate(trustedHTMLFromLegacyTemplate(this.template));
|
|
1245
1286
|
// Instantiate controller (if not already done so)
|
|
1246
1287
|
const controllerType = this.directive.controller;
|
|
1247
1288
|
const bindToController = this.directive.bindToController;
|
|
@@ -1306,10 +1347,10 @@ class UpgradeNg1ComponentAdapter {
|
|
|
1306
1347
|
setComponentProperty(name, value) {
|
|
1307
1348
|
this.destinationObj[this.propertyMap[name]] = value;
|
|
1308
1349
|
}
|
|
1309
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.
|
|
1310
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.
|
|
1350
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.3", ngImport: i0, type: UpgradeNg1ComponentAdapter, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive }); }
|
|
1351
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.3", type: UpgradeNg1ComponentAdapter, usesOnChanges: true, ngImport: i0 }); }
|
|
1311
1352
|
}
|
|
1312
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.
|
|
1353
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.3", ngImport: i0, type: UpgradeNg1ComponentAdapter, decorators: [{
|
|
1313
1354
|
type: Directive
|
|
1314
1355
|
}], ctorParameters: () => [{ type: UpgradeHelper }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }, { type: undefined }] });
|
|
1315
1356
|
|