Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FW-869: Refactor view container and view manipulations for embedded views and projections #29031

Closed
wants to merge 1 commit into from

Conversation

benlesh
Copy link
Contributor

@benlesh benlesh commented Feb 28, 2019

Views were being added to containers in such a way that they were out of sync with the order their corresponding elements existed in the DOM (and in the templates). This caused issues with how query results would come back, specifically that they would be in seemingly arbitrary order based off of the order in which they were retrieved (and therefor set up). Another side effect of this is that change detection was processed in the aforementioned order.

The fix was to refactor the view container and view interaction APIs, and rework the logic where views were being added to the container and linked to one another.

This also switches from an "insert before" strategy to an "insert after" strategy for adding DOM nodes.

Before:

<span>inserted 1</span><span>inserted 2</span><!-- container -->

After:

<!-- container --><span>inserted 1</span><span>inserted 2</span>

This also uncovered an issue related to i18n that has been marked with fixmeIvy('FW-1112: ...') in this PR. (attn @ocombe)

Thanks to @pkozlowski-opensource for the rapid assist with the query-related issue, @mhevery's guidance/ideas and @Combe for helping track down what was going on with the i18n test marked for fixing.

Update (2019-03-07) --------------

Everything was rebased as of last night at 8pm PST.

Two remaining known issue:

  • There are a few tests marked fixmeIvy('FW-????: ....'), I plan on replacing that ???? with an actual Jira number when this PR is closer to landing.
  • I have asked @ocombe to look into the remaining failing tests for i18n.

Because this is a large refactor, it's going to take a while to review and refine, so I'd like to get started with reviews prior to the above remaining issues being resolved.

@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 added cla: yes area: core Issues related to the framework runtime target: major This PR is targeted for the next major release comp: ivy risk: medium labels Feb 28, 2019
@ngbot ngbot bot added this to the needsTriage milestone Feb 28, 2019
@benlesh benlesh removed the cla: no label Feb 28, 2019
@googlebot
Copy link

A Googler has manually verified that the CLAs look good.

(Googler, please make sure the reason for overriding the CLA status is clearly documented in these comments.)

ℹ️ Googlers: Go here for more info.

@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.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

packages/core/src/render3/view.ts Outdated Show resolved Hide resolved
packages/core/src/render3/view.ts Outdated Show resolved Hide resolved
packages/core/src/render3/view.ts Outdated Show resolved Hide resolved
packages/core/src/render3/component.ts Show resolved Hide resolved
packages/core/src/render3/component_ref.ts Show resolved Hide resolved
packages/core/src/render3/i18n.ts Outdated Show resolved Hide resolved
packages/core/src/render3/instructions.ts Outdated Show resolved Hide resolved
packages/core/src/render3/instructions.ts Outdated Show resolved Hide resolved
packages/core/src/render3/instructions.ts Outdated Show resolved Hide resolved
packages/core/test/render3/content_spec.ts Outdated Show resolved Hide resolved
@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.

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes and removed cla: no labels Mar 8, 2019
@benlesh benlesh force-pushed the FW-869-start-two branch 4 times, most recently from 7fafe5e to f3f6070 Compare March 12, 2019 23:36
@benlesh benlesh force-pushed the FW-869-start-two branch 3 times, most recently from 8abede8 to ff720de Compare March 14, 2019 17:00
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.

This is a pretty beefy PR, so this is my first attempt. General approach looks good. High level things to start with would probably be:

  • Split out addition of View interface into a separate PR (can be landed before this)
  • Split out unrelated docs changes (e.g. in i18n) into a separate PR (can be landed before this)
  • Split out new public API methods (e.g. getViewContainer) into a separate PR (can be landed after this)
  • Convert tests with handwritten generated code to TestBed
  • Audit uses of NATIVE vs HOST (noticed that they are used interchangeably)

packages/core/src/linker/query_list.ts Outdated Show resolved Hide resolved
packages/core/src/render3/interfaces/view.ts Show resolved Hide resolved
packages/core/src/render3/query.ts Show resolved Hide resolved
packages/core/src/render3/util/view_utils.ts Outdated Show resolved Hide resolved
packages/core/src/render3/view.ts Show resolved Hide resolved
packages/core/src/render3/instructions.ts Outdated Show resolved Hide resolved
ngDevMode && assertLView(parentLView);
ngDevMode && assertLContainer(lContainerToAdd);

const anchorElement = lContainerToAdd[HOST];
Copy link
Contributor

@kara kara Mar 14, 2019

Choose a reason for hiding this comment

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

If you want the host node, you'll need to unwrap it to avoid getting a component view or a styling context.

Suggested change
const anchorElement = lContainerToAdd[HOST];
const anchorElement = unwrapRNode(lContainerToAdd);

Which begs the question - do you want the host node? Or are you looking specifically for a comment? In that case, it should be NATIVE.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've switched to NATIVE, because I'm sure that's what I really wanted... however it does concern me that no tests broke from me using HOST instead.

cc @mhevery

packages/core/src/render3/node_manipulation.ts Outdated Show resolved Hide resolved
packages/core/src/render3/view.ts Show resolved Hide resolved
@benlesh benlesh mentioned this pull request Mar 15, 2019
benlesh added a commit to benlesh/angular that referenced this pull request Mar 15, 2019
Just updating comments in query-related things to make it easier for the next person that has to grok this for the first time.

Also adds a demo from @mhevery to one of the query specs

Related angular#29031
@benlesh benlesh requested a review from kara March 16, 2019 00:32
matsko pushed a commit that referenced this pull request Mar 18, 2019
Just updating comments in query-related things to make it easier for the next person that has to grok this for the first time.

Also adds a demo from @mhevery to one of the query specs

Related #29031

PR Close #29342
benlesh added a commit to benlesh/angular that referenced this pull request Mar 18, 2019
Just updating comments in query-related things to make it easier for the next person that has to grok this for the first time.

Also adds a demo from @mhevery to one of the query specs

Related angular#29031
matsko pushed a commit that referenced this pull request Mar 18, 2019
Just updating comments in query-related things to make it easier for the next person that has to grok this for the first time.

Also adds a demo from @mhevery to one of the query specs

Related #29031

PR Close #29342
@benlesh
Copy link
Contributor Author

benlesh commented Mar 20, 2019

Closing this as it's replaced by #29339 and #29340. Although I'll be back to review the comments for sure.

@benlesh benlesh closed this Mar 20, 2019
wKoza pushed a commit to wKoza/angular that referenced this pull request Apr 17, 2019
Just updating comments in query-related things to make it easier for the next person that has to grok this for the first time.

Also adds a demo from @mhevery to one of the query specs

Related angular#29031

PR Close angular#29342
wKoza pushed a commit to wKoza/angular that referenced this pull request Apr 17, 2019
Just updating comments in query-related things to make it easier for the next person that has to grok this for the first time.

Also adds a demo from @mhevery to one of the query specs

Related angular#29031

PR Close angular#29342
@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
area: core Issues related to the framework runtime cla: yes 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.

None yet

5 participants