Skip to content

Commit

Permalink
[BUGFIX] Fix blockless component meta resolution
Browse files Browse the repository at this point in the history
Ensure that tagless, blockless components can render properly and can
still use local lookup
  • Loading branch information
asakusuma committed Jun 10, 2016
1 parent 3965f86 commit 3504332
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -619,16 +619,16 @@ moduleFor('@htmlbars Components test: closure components', class extends Renderi
assert.equal(this.$('.value').text(), '8');
}

['@test regression: tagless blockless components'](assert) {
assert.expect(0);

['@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(), '');
}

});
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

0 comments on commit 3504332

Please sign in to comment.