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] Fix blockless component meta resolution #13634

Merged
merged 2 commits into from
Jun 10, 2016
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 @@ -619,6 +619,18 @@ moduleFor('@htmlbars Components test: closure components', class extends Renderi
assert.equal(this.$('.value').text(), '8');
}

['@test tagless blockless components render'](assert) {
this.registerComponent('my-comp', {
ComponentClass: Component.extend({ tagName: '' })
});

this.render(`{{my-comp}}`);

this.runTask(() => this.rerender());

assert.equal(this.$().text(), '');
}

});

class ClosureComponentMutableParamsTest extends RenderingTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { moduleFor, RenderingTest } from '../../utils/test-case';
import { Component } from '../../utils/helpers';

// copied from ember-htmlbars/tests/integration/local-lookup-test.js
function buildResolver() {
Expand Down Expand Up @@ -48,6 +49,22 @@ moduleFor('Components test: local lookup', class extends RenderingTest {
this.assertText('Nested template says: Hi!', 'Re-render works');
}

['@htmlbars tagless blockless component can lookup local template'](assert) {
this.registerComponent('x-outer/x-inner', { template: 'Nested template says: {{yield}}' });
this.registerTemplate('components/x-outer', '{{#x-inner}}Hi!{{/x-inner}}');
this.registerComponent('x-outer', {
ComponentClass: Component.extend({ tagName: '' })
});

this.render('{{x-outer}}');

this.assertText('Nested template says: Hi!', 'Re-render works');

this.runTask(() => this.rerender());

this.assertText('Nested template says: Hi!', 'Re-render works');
}

['@htmlbars it can lookup a local component template']() {
this.registerTemplate('components/x-outer/x-inner', 'Nested template says: {{yield}}');
this.registerTemplate('components/x-outer', '{{#x-inner}}Hi!{{/x-inner}}');
Expand Down
10 changes: 8 additions & 2 deletions packages/ember-htmlbars/lib/hooks/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,15 @@ export default function componentHook(renderNode, env, scope, _tagName, params,

// Determine if this is an initial render or a re-render.
if (state.manager) {
let templateMeta = state.manager.block.template.meta;
let sm = state.manager;
let templateMeta = null;
if (sm.block) {
templateMeta = sm.block.template.meta;
} else if (sm.scope && sm.scope._view) {
templateMeta = sm.scope._view.template.meta;
}
env.meta.moduleName = (templateMeta && templateMeta.moduleName) || (env.meta && env.meta.moduleName);
extractPositionalParams(renderNode, state.manager.component.constructor, params, attrs, false);
extractPositionalParams(renderNode, sm.component.constructor, params, attrs, false);
state.manager.rerender(env, attrs, visitor);
return;
}
Expand Down