(index: number, pipeName: string)
| 39 | * @codeGenApi |
| 40 | */ |
| 41 | export 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, |
nothing calls this directly
no test coverage detected
searching dependent graphs…