Skip to content

Commit

Permalink
Merge pull request #12164 from EricSchank/local-layout
Browse files Browse the repository at this point in the history
[BUGFIX release-1-13] handle local template but no layout for component #12134
  • Loading branch information
rwjblue committed Aug 22, 2015
2 parents f4e708d + 473aeef commit 3f9c86a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ ComponentNodeManager.create = function(renderNode, env, options) {
// If the component specifies its template via the `layout` or `template`
// properties instead of using the template looked up in the container, get
// them now that we have the component instance.
let result = extractComponentTemplates(component, templates);
let result = extractComponentTemplates(component, templates, layout);
layout = result.layout || layout;
templates = result.templates || templates;

Expand Down Expand Up @@ -149,7 +149,7 @@ function processPositionalParams(renderNode, positionalParams, params, attrs) {
}
}

function extractComponentTemplates(component, _templates) {
function extractComponentTemplates(component, _templates, _layout) {
// Even though we looked up a layout from the container earlier, the
// component may specify a `layout` property that overrides that.
// The component may also provide a `template` property we should
Expand All @@ -169,11 +169,17 @@ function extractComponentTemplates(component, _templates) {
layout = componentLayout;
templates = extractLegacyTemplate(_templates, componentTemplate);
} else if (componentTemplate) {
// If the component has a `template` but no `layout`, use the template
// as the layout.
layout = componentTemplate;
if (_layout) {
// If the component has no `layout`, but one was found during
// `lookupComponent` in calling `create` function, use that
layout = _layout;
} else {
// If the component has a `template` but no `layout`, use the template
// as the layout.
layout = componentTemplate;
Ember.deprecate("Using deprecated `template` property on a Component.");
}
templates = _templates;
Ember.deprecate("Using deprecated `template` property on a Component.");
}

return { layout, templates };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,17 @@ QUnit.test('non-block with properties on attrs and component class', function()
equal(jQuery('#qunit-fixture').text(), 'In layout - someProp: something here');
});

QUnit.test('no local layout component', function() {
registry.register('component:foo-bar', Component.extend({
defaultTemplate: { some: 'thing' }
}));
registry.register('template:components/foo-bar', compile('In layout - no local layout'));

view = appendViewFor('{{foo-bar}}');

equal(jQuery('#qunit-fixture').text(), 'In layout - no local layout');
});

QUnit.test('rerendering component with attrs from parent', function() {
var willUpdate = 0;
var didReceiveAttrs = 0;
Expand Down

0 comments on commit 3f9c86a

Please sign in to comment.