Skip to content

Conversation

@benlesh
Copy link
Contributor

@benlesh benlesh commented Apr 17, 2019

  • Adds generation of ɵɵproperty instructions to compiler
  • Fixes issues where global state for selected index and active directives were getting out of sync.
  • Resolves an issue where selected index was being prematurely set before hooks were being executed.

Related #29881

@benlesh benlesh force-pushed the codegen-property2 branch from ae91d21 to a78163b Compare April 17, 2019 01:42
@benlesh benlesh marked this pull request as ready for review April 17, 2019 02:03
@benlesh benlesh requested review from a team April 17, 2019 02:03
@benlesh benlesh added comp: ivy target: major This PR is targeted for the next major release feature Issue that requests a new feature labels Apr 17, 2019
@ngbot ngbot bot modified the milestone: needsTriage Apr 17, 2019
@benlesh
Copy link
Contributor Author

benlesh commented Apr 17, 2019

Current integration_test failures seem to be related to an issue with incorrect version numbers in Angular CLI. 🤔

Copy link
Contributor

@mhevery mhevery left a comment

Choose a reason for hiding this comment

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

Can you explain whey all of the try-finally blocks are needed?

@mhevery mhevery self-assigned this Apr 17, 2019
Copy link
Contributor

Choose a reason for hiding this comment

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

This mapping logic (lines 757-766) is already in mapBindingToInstruction. Reuse here?

instruction = mapBindingToInstruction(inputType)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mapBindingToInstruction was removed. The way it was being used didn't make sense. For example, it was mapping for BindingType.Animation, but for no reason, because what it was mapping to wasn't even used inside the block for if (inputType === BindingType.Animation) { right below it.

Looking into your comment did reveal a funny bug though, it was still doing else if (instruction) which was always true because instruction is a function declared elsewhere in the module. :)

At the end of the day, the mapBindingToInstruction function was unnecessary indirection that wasn't even universally useful for every BindingType. I axed it in favor of simple conditionals. These are likely to change in upcoming PRs to update generated code for inrepolation too, to be even more like the check above where you see inputType === BindingType.Property && !(value instanceof Interpolation)

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for fixing the logic. I would argue that we should still move it to a separate function for readability. This function is incredibly long already, so I think inlining it actually makes the code less readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is that the BindingType does not always map 1:1 with an instruction anymore, and that's actually liable to get more complicated. I agree that the mega function sucks, but perhaps we can refactor it in another PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I see why it's hard to copy-paste that code out into a different function?

@benlesh
Copy link
Contributor Author

benlesh commented Apr 18, 2019

Can you explain whey all of the try-finally blocks are needed?

@mhevery There are several situations where updating a property causes child views to synchronously render. For example when you update an ngIf property, it may call the template function for an embedded view synchronously. When those templates execute, they reset the selected index to -1 to start with, then they have their own ɵɵselect instructions inside of them which also alter the selected index state. Since the selected index is shared, global state, we need to set it back when we're done, even if there's an error.

@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

ℹ️ Googlers: Go here for more info.

1 similar comment
@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

ℹ️ Googlers: Go here for more info.

@benlesh benlesh force-pushed the codegen-property2 branch from 1e727e0 to e49058a Compare April 18, 2019 21:52
@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@benlesh benlesh requested review from kara and mhevery April 18, 2019 21:54
Copy link
Contributor

@mhevery mhevery left a comment

Choose a reason for hiding this comment

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

LGTM, please resolve comments from other.

Copy link
Contributor

@kara kara left a comment

Choose a reason for hiding this comment

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

LGTM, a few more nits and should be good

@kara kara added the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Apr 19, 2019
@kara kara assigned benlesh and unassigned mhevery Apr 19, 2019
@benlesh benlesh added action: merge The PR is ready for merge by the caretaker 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 Apr 19, 2019
@benlesh benlesh closed this in 10217bb Apr 19, 2019
@benlesh benlesh deleted the codegen-property2 branch April 19, 2019 23:13
BioPhoton pushed a commit to BioPhoton/angular that referenced this pull request May 21, 2019
BioPhoton pushed a commit to BioPhoton/angular that referenced this pull request May 21, 2019
@angular-automatic-lock-bot
Copy link

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 14, 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 feature Issue that requests a new feature risk: medium target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants