From 22721f2567daf9f6c7a0a306fe352b5ab9792264 Mon Sep 17 00:00:00 2001 From: asakusuma Date: Fri, 2 Sep 2016 11:36:21 -0700 Subject: [PATCH 1/2] Add failing test around moduleName mutation --- .../integration/components/local-lookup-test.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/ember-glimmer/tests/integration/components/local-lookup-test.js b/packages/ember-glimmer/tests/integration/components/local-lookup-test.js index b0159ce8e4e..02c5252466a 100644 --- a/packages/ember-glimmer/tests/integration/components/local-lookup-test.js +++ b/packages/ember-glimmer/tests/integration/components/local-lookup-test.js @@ -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}}'); From 4f9383df68d517815cc8a87b59a6508f6e01a052 Mon Sep 17 00:00:00 2001 From: Kris Selden Date: Tue, 6 Sep 2016 13:06:11 -0700 Subject: [PATCH 2/2] [BUGFIX release] Fixes #14192 Ensure rerender in ComponentNodeManager passes meta the same way as it does in render. Remove invalid fix to above issue that caused moduleName to be incorrectly mutated. --- packages/ember-htmlbars/lib/hooks/component.js | 14 ++------------ .../lib/node-managers/component-node-manager.js | 3 ++- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/packages/ember-htmlbars/lib/hooks/component.js b/packages/ember-htmlbars/lib/hooks/component.js index b9106337acc..c46fb952250 100644 --- a/packages/ember-htmlbars/lib/hooks/component.js +++ b/packages/ember-htmlbars/lib/hooks/component.js @@ -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, { diff --git a/packages/ember-htmlbars/lib/node-managers/component-node-manager.js b/packages/ember-htmlbars/lib/node-managers/component-node-manager.js index 592427f9a59..f3a29c7f33b 100644 --- a/packages/ember-htmlbars/lib/node-managers/component-node-manager.js +++ b/packages/ember-htmlbars/lib/node-managers/component-node-manager.js @@ -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);