MCPcopy
hub / github.com/angular/angular / ɵɵpipe

Function ɵɵpipe

packages/core/src/render3/pipe.ts:41–82  ·  view source on GitHub ↗
(index: number, pipeName: string)

Source from the content-addressed store, hash-verified

39 * @codeGenApi
40 */
41export function ɵɵpipe(index: number, pipeName: string): any {
42 const tView = getTView();
43 let pipeDef: PipeDef<any>;
44 const adjustedIndex = index + HEADER_OFFSET;
45
46 if (tView.firstCreatePass) {
47 // The `getPipeDef` throws if a pipe with a given name is not found
48 // (so we use non-null assertion below).
49 pipeDef = getPipeDef(pipeName, tView.pipeRegistry)!;
50 tView.data[adjustedIndex] = pipeDef;
51 if (pipeDef.onDestroy) {
52 (tView.destroyHooks ??= []).push(adjustedIndex, pipeDef.onDestroy);
53 }
54 } else {
55 pipeDef = tView.data[adjustedIndex] as PipeDef<any>;
56 }
57
58 const pipeFactory = pipeDef.factory || (pipeDef.factory = getFactoryDef(pipeDef.type, true));
59
60 let previousInjectorProfilerContext: InjectorProfilerContext;
61 if (ngDevMode) {
62 previousInjectorProfilerContext = setInjectorProfilerContext({
63 injector: new NodeInjector(getCurrentTNode() as TTextNode, getLView()),
64 token: pipeDef.type,
65 });
66 }
67 const previousInjectImplementation = setInjectImplementation(ɵɵdirectiveInject);
68 try {
69 // DI for pipes is supposed to behave like directives when placed on a component
70 // host node, which means that we have to disable access to `viewProviders`.
71 const previousIncludeViewProviders = setIncludeViewProviders(false);
72 const pipeInstance = pipeFactory();
73 setIncludeViewProviders(previousIncludeViewProviders);
74 store(tView, getLView(), adjustedIndex, pipeInstance);
75 return pipeInstance;
76 } finally {
77 // we have to restore the injector implementation in finally, just in case the creation of the
78 // pipe throws an error.
79 setInjectImplementation(previousInjectImplementation);
80 ngDevMode && setInjectorProfilerContext(previousInjectorProfilerContext!);
81 }
82}
83
84/**
85 * Searches the pipe registry for a pipe with the given name. If one is found,

Callers

nothing calls this directly

Calls 10

getTViewFunction · 0.90
getFactoryDefFunction · 0.90
getCurrentTNodeFunction · 0.90
getLViewFunction · 0.90
setInjectImplementationFunction · 0.90
setIncludeViewProvidersFunction · 0.90
storeFunction · 0.90
getPipeDefFunction · 0.70
pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…