perf(core): make sanitization tree-shakable in Ivy mode (#31934)
In VE the `Sanitizer` is always available in `BrowserModule` because the VE retrieves it using injection. In Ivy the injection is optional and we have instructions instead of component definition arrays. The implication of this is that in Ivy the instructions can pull in the sanitizer only when they are working with a property which is known to be unsafe. Because the Injection is optional this works even if no Sanitizer is present. So in Ivy we first use the sanitizer which is pulled in by the instruction, unless one is available through the `Injector` then we use that one instead. This PR does few things: 1) It makes `Sanitizer` optional in Ivy. 2) It makes `DomSanitizer` tree shakable. 3) It aligns the semantics of Ivy `Sanitizer` with that of the Ivy sanitization rules. 4) It refactors `DomSanitizer` to use same functions as Ivy sanitization for consistency. PR Close #31934
This commit is contained in:

committed by
Andrew Kushnir

parent
40b28742a9
commit
2e4d17f3a9
@ -84,12 +84,11 @@ export class CompilerImpl implements Compiler {
|
||||
return meta && meta.id || undefined;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A set of providers that provide `JitCompiler` and its dependencies to use for
|
||||
* template compilation.
|
||||
*/
|
||||
export const COMPILER_PROVIDERS = <StaticProvider[]>[
|
||||
const COMPILER_PROVIDERS__PRE_R3__ = <StaticProvider[]>[
|
||||
{provide: CompileReflector, useValue: new JitReflector()},
|
||||
{provide: ResourceLoader, useValue: _NO_RESOURCE_LOADER},
|
||||
{provide: JitSummaryResolver, deps: []},
|
||||
@ -156,6 +155,9 @@ export const COMPILER_PROVIDERS = <StaticProvider[]>[
|
||||
{ provide: NgModuleResolver, deps: [CompileReflector]},
|
||||
];
|
||||
|
||||
export const COMPILER_PROVIDERS__POST_R3__ =
|
||||
<StaticProvider[]>[{provide: Compiler, useFactory: () => new Compiler()}];
|
||||
export const COMPILER_PROVIDERS = COMPILER_PROVIDERS__PRE_R3__;
|
||||
/**
|
||||
* @publicApi
|
||||
*/
|
||||
|
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
|
||||
export {CompilerImpl as ɵCompilerImpl} from './compiler_factory';
|
||||
export {COMPILER_PROVIDERS__POST_R3__ as ɵCOMPILER_PROVIDERS__POST_R3__, CompilerImpl as ɵCompilerImpl} from './compiler_factory';
|
||||
export {platformCoreDynamic as ɵplatformCoreDynamic} from './platform_core_dynamic';
|
||||
export {INTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS as ɵINTERNAL_BROWSER_DYNAMIC_PLATFORM_PROVIDERS} from './platform_providers';
|
||||
export {ResourceLoaderImpl as ɵResourceLoaderImpl} from './resource_loader/resource_loader_impl';
|
||||
|
Reference in New Issue
Block a user