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 beta] Ensure view registry is provided to components. #11270

Merged
merged 1 commit into from
May 25, 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 @@ -253,6 +253,8 @@ export function createComponent(_component, isAngleBracket, _props, renderNode,
}

props.renderer = props.parentView ? props.parentView.renderer : env.container.lookup('renderer:-dom');
props._viewRegistry = props.parentView ? props.parentView._viewRegistry : props.container && props.container.lookup('-view-registry:main');

let component = _component.create(props);

// for the fallback case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ export function createOrUpdateComponent(component, options, createOptions, rende
mergeBindings(props, shadowedAttrs(proto, snapshot));
props.container = options.parentView ? options.parentView.container : env.container;
props.renderer = options.parentView ? options.parentView.renderer : props.container && props.container.lookup('renderer:-dom');
props._viewRegistry = options.parentView ? options.parentView._viewRegistry : props.container && props.container.lookup('-view-registry:main');

if (proto.controller !== defaultController || hasSuppliedController) {
delete props._context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,47 @@ 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("components should receive the viewRegistry from the parent view", function() {
var outer, innerTemplate, innerLayout;

var viewRegistry = {};

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

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

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

registry.register('template:components/x-outer', compile('{{x-inner-in-layout}}{{yield}}'));

view = EmberView.extend({
_viewRegistry: viewRegistry,
template: compile('{{#x-outer}}{{x-inner-in-template}}{{/x-outer}}'),
container: container
}).create();

runAppend(view);

equal(innerTemplate._viewRegistry, viewRegistry);
Copy link
Member

Choose a reason for hiding this comment

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

should this also test that w/e uses viewRegistry works correctly?

Copy link
Member Author

Choose a reason for hiding this comment

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

By default _viewRegistry is Ember.View.views, but that does not work in the fastboot or multiple app scenario (because there are two different view registries).


This change, ensures that the _viewRegistry is passed down through the various views/components created during render (it was previously not passed through). It does not actually test that things use _viewRegistry (though they should).

Copy link
Member Author

Choose a reason for hiding this comment

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

@stefanpenner - Thanks for poking me into looking into the usage side of this, #11290 fixes an issue with the event dispatcher that broke multiple apps on the page...

Copy link
Member

Choose a reason for hiding this comment

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

👍

equal(innerLayout._viewRegistry, viewRegistry);
equal(outer._viewRegistry, viewRegistry);
});

QUnit.test("comopnent should rerender when a property (with a default) is changed during children's rendering", function() {
expectDeprecation(/modified value twice in a single render/);

Expand Down