@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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Angular v18.2.1
2
+ * @license Angular v18.2.3
3
3
  * (c) 2010-2024 Google LLC. https://angular.io/
4
4
  * License: MIT
5
5
  */
@@ -922,7 +922,48 @@ function downgradeInjectable(token, downgradedModule = '') {
922
922
  /**
923
923
  * @publicApi
924
924
  */
925
- const VERSION = new Version('18.2.1');
925
+ const VERSION = new Version('18.2.3');
926
+
927
+ /**
928
+ * The Trusted Types policy, or null if Trusted Types are not
929
+ * enabled/supported, or undefined if the policy has not been created yet.
930
+ */
931
+ let policy;
932
+ /**
933
+ * Returns the Trusted Types policy, or null if Trusted Types are not
934
+ * enabled/supported. The first call to this function will create the policy.
935
+ */
936
+ function getPolicy() {
937
+ if (policy === undefined) {
938
+ policy = null;
939
+ const windowWithTrustedTypes = window;
940
+ if (windowWithTrustedTypes.trustedTypes) {
941
+ try {
942
+ policy = windowWithTrustedTypes.trustedTypes.createPolicy('angular#unsafe-upgrade', {
943
+ createHTML: (s) => s,
944
+ });
945
+ }
946
+ catch {
947
+ // trustedTypes.createPolicy throws if called with a name that is
948
+ // already registered, even in report-only mode. Until the API changes,
949
+ // catch the error not to break the applications functionally. In such
950
+ // cases, the code will fall back to using strings.
951
+ }
952
+ }
953
+ }
954
+ return policy;
955
+ }
956
+ /**
957
+ * Unsafely promote a legacy AngularJS template to a TrustedHTML, falling back
958
+ * to strings when Trusted Types are not available.
959
+ * @security This is a security-sensitive function; any use of this function
960
+ * must go through security review. In particular, the template string should
961
+ * always be under full control of the application author, as untrusted input
962
+ * can cause an XSS vulnerability.
963
+ */
964
+ function trustedHTMLFromLegacyTemplate(html) {
965
+ return getPolicy()?.createHTML(html) || html;
966
+ }
926
967
 
927
968
  // Constants
928
969
  const REQUIRE_PREFIX_RE = /^(\^\^?)?(\?)?(\^\^?)?/;
@@ -955,14 +996,14 @@ class UpgradeHelper {
955
996
  }
956
997
  static getTemplate($injector, directive, fetchRemoteTemplate = false, $element) {
957
998
  if (directive.template !== undefined) {
958
- return getOrCall(directive.template, $element);
999
+ return trustedHTMLFromLegacyTemplate(getOrCall(directive.template, $element));
959
1000
  }
960
1001
  else if (directive.templateUrl) {
961
1002
  const $templateCache = $injector.get($TEMPLATE_CACHE);
962
1003
  const url = getOrCall(directive.templateUrl, $element);
963
1004
  const template = $templateCache.get(url);
964
1005
  if (template !== undefined) {
965
- return template;
1006
+ return trustedHTMLFromLegacyTemplate(template);
966
1007
  }
967
1008
  else if (!fetchRemoteTemplate) {
968
1009
  throw new Error('loading directive templates asynchronously is not supported');
@@ -971,7 +1012,7 @@ class UpgradeHelper {
971
1012
  const $httpBackend = $injector.get($HTTP_BACKEND);
972
1013
  $httpBackend('GET', url, null, (status, response) => {
973
1014
  if (status === 200) {
974
- resolve($templateCache.put(url, response));
1015
+ resolve(trustedHTMLFromLegacyTemplate($templateCache.put(url, response)));
975
1016
  }
976
1017
  else {
977
1018
  reject(`GET component template from '${url}' returned '${status}: ${response}'`);
@@ -1631,10 +1672,10 @@ class UpgradeComponent {
1631
1672
  bindingDestination.$onChanges(changes);
1632
1673
  }
1633
1674
  }
1634
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.1", ngImport: i0, type: UpgradeComponent, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive }); }
1635
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.1", type: UpgradeComponent, usesOnChanges: true, ngImport: i0 }); }
1675
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.3", ngImport: i0, type: UpgradeComponent, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive }); }
1676
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "18.2.3", type: UpgradeComponent, usesOnChanges: true, ngImport: i0 }); }
1636
1677
  }
1637
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.1", ngImport: i0, type: UpgradeComponent, decorators: [{
1678
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.3", ngImport: i0, type: UpgradeComponent, decorators: [{
1638
1679
  type: Directive
1639
1680
  }], ctorParameters: () => [{ type: undefined }, { type: i0.ElementRef }, { type: i0.Injector }] });
1640
1681
 
@@ -1910,11 +1951,11 @@ class UpgradeModule {
1910
1951
  }
1911
1952
  return returnValue;
1912
1953
  }
1913
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.1", ngImport: i0, type: UpgradeModule, deps: [{ token: i0.Injector }, { token: i0.NgZone }, { token: i0.PlatformRef }], target: i0.ɵɵFactoryTarget.NgModule }); }
1914
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.1", ngImport: i0, type: UpgradeModule }); }
1915
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.1", ngImport: i0, type: UpgradeModule, providers: [angular1Providers] }); }
1954
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "18.2.3", ngImport: i0, type: UpgradeModule, deps: [{ token: i0.Injector }, { token: i0.NgZone }, { token: i0.PlatformRef }], target: i0.ɵɵFactoryTarget.NgModule }); }
1955
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "18.2.3", ngImport: i0, type: UpgradeModule }); }
1956
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "18.2.3", ngImport: i0, type: UpgradeModule, providers: [angular1Providers] }); }
1916
1957
  }
1917
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.1", ngImport: i0, type: UpgradeModule, decorators: [{
1958
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.2.3", ngImport: i0, type: UpgradeModule, decorators: [{
1918
1959
  type: NgModule,
1919
1960
  args: [{ providers: [angular1Providers] }]
1920
1961
  }], ctorParameters: () => [{ type: i0.Injector }, { type: i0.NgZone }, { type: i0.PlatformRef }] });