Skip to content

Commit

Permalink
Merge pull request #14219 from emberjs/fix-meta-mutation
Browse files Browse the repository at this point in the history
Fix meta mutation #14192
  • Loading branch information
rwjblue authored Sep 6, 2016
2 parents 9423fc6 + 4f9383d commit a36823c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ moduleFor('Components test: local lookup', class extends RenderingTest {
this.assertText('Nested template says: Hi!', 'Re-render works');
}

['@test moduleName remains unchanged']() {
this.registerComponent('x-outer/x-inner', { template: 'Nested template says: {{yield}}' });
this.registerComponent('x-outer', { template: '{{#x-inner}}Hi!{{/x-inner}}' });
this.registerComponent('x-root', { template: '{{x-outer}}' });

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

let moduleName = this.owner.lookup('template:-top-level').meta.moduleName;

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

this.assert.equal(moduleName, this.owner.lookup('template:-top-level').meta.moduleName, 'moduleName is unchanged after re-render');
}

['@test 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}}');
Expand Down
14 changes: 2 additions & 12 deletions packages/ember-htmlbars/lib/hooks/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,16 @@ export default function componentHook(renderNode, env, scope, _tagName, params,
// Determine if this is an initial render or a re-render.
if (state.manager) {
let sm = state.manager;
let templateMeta = null;
if (sm.block) {
templateMeta = sm.block.template.meta;
} else if (sm.scope && sm.scope._view && sm.scope._view.template) {
templateMeta = sm.scope._view.template.meta;
}
env.meta.moduleName = (templateMeta && templateMeta.moduleName) || (env.meta && env.meta.moduleName);
extractPositionalParams(renderNode, sm.component.constructor, params, attrs, false);
state.manager.rerender(env, attrs, visitor);
return;
}

let parentView = env.view;
let options = { };

let moduleName = env.meta && env.meta.moduleName;
if (moduleName) {
options.source = `template:${moduleName}`;
}
let options = { source: moduleName && `template:${moduleName}` };
let { component, layout } = lookupComponent(env.owner, tagName, options);

assert(`HTMLBars error: Could not find component named "${tagName}" (no component or template with that name was found)`, !!(component || layout));

let manager = ComponentNodeManager.create(renderNode, env, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ ComponentNodeManager.prototype.rerender = function ComponentNodeManager_rerender
let component = this.component;

return instrument(component, function ComponentNodeManager_rerender_instrument() {
let env = _env.childWithView(component);
let meta = this.block && this.block.template.meta;
let env = _env.childWithView(component, meta);

let snapshot = takeSnapshot(attrs);

Expand Down

0 comments on commit a36823c

Please sign in to comment.