Skip to content

fix(ivy): incorrect ChangeDetectorRef injected into pipes used in component inputs - #31438

Closed
crisbeto wants to merge 2 commits into
angular:masterfrom
crisbeto:FW-1419/pipe-change-detector-ref
Closed

crisbeto wants to merge 2 commits into
angular:masterfrom
crisbeto:FW-1419/pipe-change-detector-ref

Conversation

@crisbeto

@crisbeto crisbeto commented Jul 6, 2019

Copy link
Copy Markdown
Member

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.

@crisbeto crisbeto added comp: ivy target: major This PR is targeted for the next major release type: bug/fix labels Jul 6, 2019
@ngbot ngbot Bot added this to the needsTriage milestone Jul 6, 2019
@crisbeto crisbeto added the action: review The PR is still awaiting reviews from at least one requested reviewer label Jul 6, 2019
@crisbeto
crisbeto marked this pull request as ready for review July 6, 2019 08:25
@crisbeto
crisbeto requested a review from a team July 6, 2019 08:25
@crisbeto
crisbeto force-pushed the FW-1419/pipe-change-detector-ref branch from 54e83de to 6968e8c Compare July 6, 2019 10:11
@LayZeeDK

LayZeeDK commented Jul 6, 2019

Copy link
Copy Markdown
Contributor

Stumbled upon by @BioPhoton. Investigated by @JoostK.

Thanks for fixing!

@kara kara added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jul 9, 2019
@crisbeto
crisbeto force-pushed the FW-1419/pipe-change-detector-ref branch from 6968e8c to 9f502a9 Compare July 12, 2019 18:15
@crisbeto
crisbeto requested review from a team July 12, 2019 18:15
@crisbeto crisbeto removed their assignment Jul 12, 2019
@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Jul 12, 2019
@crisbeto

Copy link
Copy Markdown
Member Author

@kara I've reworked it based on our discussion. Can you take another look?

@kara kara left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kara kara added action: presubmit The PR is in need of a google3 presubmit action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jul 17, 2019
@kara

kara commented Jul 17, 2019

Copy link
Copy Markdown
Contributor

VE presubmit

Ivy presubmit

@kara kara removed the action: merge The PR is ready for merge by the caretaker label Jul 17, 2019
@crisbeto
crisbeto force-pushed the FW-1419/pipe-change-detector-ref branch from c17c052 to 20f941b Compare July 19, 2019 16:59
@crisbeto crisbeto removed their assignment Jul 19, 2019
@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Jul 19, 2019
@crisbeto

Copy link
Copy Markdown
Member Author

Reworked to avoid the circular import @kara.

@kara

kara commented Jul 19, 2019 •

Copy link
Copy Markdown
Contributor

Still getting a cyclic dep error:


packages/core/src/render3/di.ts -> packages/core/public_api.ts -> packages/core/src/core.ts -> 
packages/core/src/metadata.ts -> packages/core/src/di.ts -> packages/core/src/di/index.ts -> 
packages/core/src/di/injectable.ts -> packages/core/src/di/jit/injectable.ts -> 
packages/core/src/di/jit/util.ts -> packages/core/src/change_detection/change_detector_ref.ts -> 
packages/core/src/render3/view_engine_compatibility.ts -> packages/core/src/render3/di.ts

Looks like the culprit is jit_util adding an import to ChangeDetectorRef

@kara kara added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jul 19, 2019
…ponent inputs

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.
@crisbeto
crisbeto force-pushed the FW-1419/pipe-change-detector-ref branch from 20f941b to f4753c3 Compare July 21, 2019 11:28
@crisbeto

Copy link
Copy Markdown
Member Author

Updated again @kara. For future reference, is there a way I can check this myself so we don't have to go back and forth as much?

@crisbeto crisbeto added action: review The PR is still awaiting reviews from at least one requested reviewer and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Jul 21, 2019
@crisbeto crisbeto removed their assignment Jul 21, 2019
@crisbeto
crisbeto force-pushed the FW-1419/pipe-change-detector-ref branch from f4753c3 to 0f621ec Compare July 21, 2019 19:17
@kara

kara commented Jul 23, 2019

Copy link
Copy Markdown
Contributor

@kara kara left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kara kara added action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Jul 23, 2019
@kara

kara commented Jul 23, 2019

Copy link
Copy Markdown
Contributor

merge-assistance: global approval

@kara kara closed this in 0aff4a6 Jul 23, 2019
sabeersulaiman pushed a commit to sabeersulaiman/angular that referenced this pull request Sep 6, 2019
…ponent inputs (angular#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 angular#31438
@angular-automatic-lock-bot

Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Sep 15, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: yes merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note target: major This PR is targeted for the next major release type: bug/fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants