angular/packages/core/src/sanitization
Paul Gschwendtner 810b0a7e5c refactor: add explicit types for exports relying on inferred call return type (#61312)
As part of the Bazel toolchain migration we noticed that implicit types
generated by the TypeScript compiler sometimes end up referencing types
from other packages (i.e. cross-package imports).

These imports currently work just because the Bazel `ts_library` and
`ng_module` rules automatically inserted a `<amd-module
name="@angular/x" />` into `.d.ts` of packages. This helped TS figure
out how to import a given file. Notably this is custom logic that is not
occuring in vanilla TS or Angular compilations—so we will drop this
magic as part of the toolchain cleanup!

To improve code quality and keep the existing behavior working, we are
doing the following:

- adding a lint rule that reduces the risk of such imports breaking. The
  failure scenario without the rule is that API goldens show unexpected
  diffs, and types might be duplicated in a different package!

- keeping the `<amd-module` headers, but we manually insert them into
  the package entry-points. This should ensure we don't regress
  anywhere; while we also improved general safety around this above.

Long-term, isolated declarations or a lint rule from eslint-typescript
can make this even more robust.

PR Close #61312
2025-05-13 22:45:18 +00:00
..
bypass.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
html_sanitizer.ts refactor: add explicit types for exports relying on inferred call return type (#61312) 2025-05-13 22:45:18 +00:00
iframe_attrs_validation.ts refactor(core): move DOM manipulation logic to its own file (#59462) 2025-01-16 10:38:44 -08:00
inert_body.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
readme.md refactor(core): move sanitization into core (#22540) 2018-03-07 18:24:06 -08:00
sanitization.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
sanitizer.ts refactor: add @__PURE__ next to @pureOrBreakMyCode for improved bundler compatibility (#58297) 2024-10-28 12:26:05 -07:00
security.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00
url_sanitizer.ts refactor: update license text to point to angular.dev (#57901) 2024-09-24 15:33:00 +02:00

Sanitization

This folder contains sanitization related code.

History

It used to be that sanitization related code used to be in @angular/platform-browser since it is platform related. While this is true, in practice the compiler schema is permanently tied to the DOM and hence the fact that sanitizer could in theory be replaced is not used in practice.

In order to better support tree shaking we need to be able to refer to the sanitization functions from the Ivy code. For this reason the code has been moved into the @angular/core.