fix(ivy): error in AOT when pipe inherits constructor from injectable that uses DI (#35468)
When a pipe inherits its constructor, and as a result its factory, from an injectable in AOT mode, it can end up throwing an error, because the inject implementation hasn't been set yet. These changes ensure that the implementation is set before the pipe's factory is invoked. Note that this isn't a problem in JIT mode, because the factory inheritance works slightly differently, hence why this test isn't going through `TestBed`. Fixes #35277. PR Close #35468
This commit is contained in:
@ -8,9 +8,10 @@
|
||||
|
||||
import {WrappedValue} from '../change_detection/change_detection_util';
|
||||
import {PipeTransform} from '../change_detection/pipe_transform';
|
||||
import {setInjectImplementation} from '../di/injector_compatibility';
|
||||
|
||||
import {getFactoryDef} from './definition';
|
||||
import {store} from './instructions/all';
|
||||
import {store, ɵɵdirectiveInject} from './instructions/all';
|
||||
import {PipeDef, PipeDefList} from './interfaces/definition';
|
||||
import {HEADER_OFFSET, LView, TVIEW} from './interfaces/view';
|
||||
import {pureFunction1Internal, pureFunction2Internal, pureFunction3Internal, pureFunction4Internal, pureFunctionVInternal} from './pure_function';
|
||||
@ -45,7 +46,9 @@ export function ɵɵpipe(index: number, pipeName: string): any {
|
||||
}
|
||||
|
||||
const pipeFactory = pipeDef.factory || (pipeDef.factory = getFactoryDef(pipeDef.type, true));
|
||||
const previousInjectImplementation = setInjectImplementation(ɵɵdirectiveInject);
|
||||
const pipeInstance = pipeFactory();
|
||||
setInjectImplementation(previousInjectImplementation);
|
||||
store(tView, getLView(), index, pipeInstance);
|
||||
return pipeInstance;
|
||||
}
|
||||
|
Reference in New Issue
Block a user