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

[REGRESSION] On re-render, newly-added sub-views of non-dirty parent components have wrong parentView #11554

Closed
jder opened this issue Jun 25, 2015 · 3 comments

Comments

@jder
Copy link
Contributor

jder commented Jun 25, 2015

It appears that 1.13.0 through 1.13.2 have a bug relative to 1.12.2 in which newly-added items in an each loop get a parentView set to the template's view rather than the component in which they appear in the template. Here is a JS bin demonstrating the issue:

http://jsbin.com/butavikavi/edit?html,js,console,output

Essentially, code like this:

{{#parent-component}}{{#each ...}}{{child-component}}{{/each}}{{/parent-component}}

The child components will have parent-component as their parentView, but on re-render if a new child-component appears, its parent view will be whatever view houses the template, not the parent-component.

@jder
Copy link
Contributor Author

jder commented Jun 26, 2015

This has the same behavior in v2.0.0-beta.1 as in 1.13.2.

@jder jder changed the title [REGRESSION] On re-render, newly-added items in {{each}} have wrong parentView [REGRESSION] On re-render, newly-added items in {{#each}} have wrong parentView Jun 27, 2015
@jder
Copy link
Contributor Author

jder commented Jul 4, 2015

I'm looking more into this. So far, I've found that this isn't {{#each}}-specific; you can reproduce the same thing with an {{#if}}, as well, if a new view is added.

jder added a commit to jder/ember.js that referenced this issue Jul 4, 2015
…ents get the correct parentView

On re-render of a non-dirty component, the `env` was simply passed down when
rendering the component's template, which means its parentView was wrong; this
patch mimics what keywords already do to solve this for components.

Fixes emberjs#11554
@jder
Copy link
Contributor Author

jder commented Jul 4, 2015

I've put together a PR for this. It's a bit of a hack, and there's probably a nicer solution possible; feedback welcome. At least, there's a simple test case in there someone could reuse.

The problem seems to come down to the fact that when a parent component is not dirty, HTMLBars never asks for it to generate an env for its children. This is solved for keywords with a special check while visiting all nodes, which is hooked up to the childEnv function on keywords. There's no equivalent place for components to provide such a callback, so I'm populating it directly on the node.

Perhaps the problem is that the env is not the right place to store this info in the first place?

@jder jder changed the title [REGRESSION] On re-render, newly-added items in {{#each}} have wrong parentView [REGRESSION] On re-render, newly-added sub-views of non-dirty parent components have wrong parentView Jul 4, 2015
rwjblue pushed a commit that referenced this issue Jul 6, 2015
…ents get the correct parentView

On re-render of a non-dirty component, the `env` was simply passed down when
rendering the component's template, which means its parentView was wrong; this
patch mimics what keywords already do to solve this for components.

Fixes #11554

(cherry picked from commit bc9dbcd)
@rwjblue rwjblue closed this as completed in 35f8a35 Jul 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants