Please sign in to comment.
fix(ivy): ensure that the correct `document` is available
Most of the use of `document` in the framework is within the DI so they just inject the `DOCUMENT` token and are done. Ivy is special because it does not rely upon the DIand must get hold of the document some other way. There are a limited number of places relevant to ivy that currently consume a global document object. The solution is modelled on the `LOCALE_ID` approach, which has `getLocaleId()` and `setLocaleId()` top-level functions for ivy (see `core/src/render3/i18n.ts`). In the rest of Angular (i.e. using DI) the `LOCALE_ID` token has a provider that also calls setLocaleId() to ensure that ivy has the same value. This commit defines `getDocument()` and `setDocument() `top-level functions for ivy. Wherever ivy needs the global `document`, it calls `getDocument()` instead. Each of the platforms (e.g. Browser, Server, WebWorker) have providers for `DOCUMENT`. In each of those providers they also call `setDocument()` accordingly. Fixes angular#33651
- Loading branch information
Showing with 59 additions and 14 deletions.
- +4 −0 packages/core/src/core_render3_private_export.ts
- +2 −2 packages/core/src/render3/i18n.ts
- +21 −3 packages/core/src/render3/interfaces/renderer.ts
- +2 −1 packages/core/src/sanitization/sanitization.ts
- +6 −0 packages/core/test/bundling/cyclic_import/bundle.golden_symbols.json
- +6 −0 packages/core/test/bundling/hello_world/bundle.golden_symbols.json
- +6 −0 packages/core/test/bundling/todo/bundle.golden_symbols.json
- +3 −1 packages/platform-browser/src/browser.ts
- +6 −6 packages/platform-server/src/server.ts
- +3 −1 packages/platform-webworker/src/worker_render.ts