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

[BUGFIX release] On re-render, ensure child views of non-dirty components get the correct parentView #11651

Merged
merged 1 commit into from
Jul 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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