fix(ivy): incorrect ChangeDetectorRef injected into pipes used in component inputs (#31438)
When injecting a `ChangeDetectorRef` into a pipe, the expected result is that the ref will be tied to the component in which the pipe is being used. This works for most cases, however when a pipe is used inside a property binding of a component (see test case as an example), the current `TNode` is pointing to component's host so we end up injecting the inner component's view. These changes fix the issue by only looking up the component view of the `TNode` if the `TNode` is a parent. This PR resolves FW-1419. PR Close #31438
This commit is contained in:
@ -49,6 +49,7 @@ export function getConstructorDependencies(
|
||||
let token = valueReferenceToExpression(param.typeValueReference, defaultImportRecorder);
|
||||
let optional = false, self = false, skipSelf = false, host = false;
|
||||
let resolved = R3ResolvedDependencyType.Token;
|
||||
|
||||
(param.decorators || []).filter(dec => isCore || isAngularCore(dec)).forEach(dec => {
|
||||
const name = isCore || dec.import === null ? dec.name : dec.import !.name;
|
||||
if (name === 'Inject') {
|
||||
@ -79,6 +80,11 @@ export function getConstructorDependencies(
|
||||
ErrorCode.DECORATOR_UNEXPECTED, dec.node, `Unexpected decorator ${name} on parameter.`);
|
||||
}
|
||||
});
|
||||
|
||||
if (token instanceof ExternalExpr && token.value.name === 'ChangeDetectorRef' &&
|
||||
token.value.moduleName === '@angular/core') {
|
||||
resolved = R3ResolvedDependencyType.ChangeDetectorRef;
|
||||
}
|
||||
if (token === null) {
|
||||
errors.push({
|
||||
index: idx,
|
||||
|
Reference in New Issue
Block a user