Skip to content

Commit

Permalink
Merge pull request #11651 from jder/stable
Browse files Browse the repository at this point in the history
[BUGFIX release] On re-render, ensure child views of non-dirty components get the correct parentView
  • Loading branch information
stefanpenner committed Jul 6, 2015
2 parents af6727d + bc9dbcd commit c3accfb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ export function createComponent(_component, isAngleBracket, _props, renderNode,

component._renderNode = renderNode;
renderNode.emberView = component;
renderNode.buildChildEnv = buildChildEnv;
return component;
}

Expand Down Expand Up @@ -360,3 +361,7 @@ function mergeBindings(target, attrs) {

return target;
}

function buildChildEnv(state, env) {
return env.childWithView(this.emberView);
}
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,37 @@ QUnit.test("components in template of a yielding component should have the prope
equal(outer.parentView, view, 'x-outer receives the ambient scope as its parentView');
});

QUnit.test('newly-added sub-components get correct parentView', function() {
var outer, inner;

registry.register('component:x-outer', Component.extend({
init() {
this._super(...arguments);
outer = this;
}
}));

registry.register('component:x-inner', Component.extend({
init() {
this._super(...arguments);
inner = this;
}
}));

view = EmberView.extend({
template: compile('{{#x-outer}}{{#if view.showInner}}{{x-inner}}{{/if}}{{/x-outer}}'),
container: container,
showInner: false
}).create();

runAppend(view);

run(() => { view.set('showInner', true); });

equal(inner.parentView, outer, 'receives the wrapping component as its parentView in template blocks');
equal(outer.parentView, view, 'x-outer receives the ambient scope as its parentView');
});

QUnit.test("components should receive the viewRegistry from the parent view", function() {
var outer, innerTemplate, innerLayout;

Expand Down

0 comments on commit c3accfb

Please sign in to comment.