Skip to content

Commit

Permalink
Fix template name (emberjs#1085)
Browse files Browse the repository at this point in the history
This hasn't been working for a while
  • Loading branch information
chancancode authored and nummi committed Apr 1, 2020
1 parent 21cd7d2 commit bc6809c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion ember_debug/libs/glimmer-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,8 @@ export default class {
* @return {String} The layout's name
*/
nameFromLayout(layout) {
let moduleName = layout && get(layout, 'meta.moduleName');
let moduleName = layout && get(layout, 'referrer.moduleName');

if (moduleName) {
return moduleName.replace(/\.hbs$/, '');
}
Expand Down
13 changes: 11 additions & 2 deletions tests/ember_debug/view-debug-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,15 @@ const EmberDebug = require('ember-debug/main').default;
let port;
let App;

function setTemplate(name, template) {
this.owner.register(`template:${name}`, template);
function setTemplate(name, factory) {
if (typeof factory.meta === 'object') {
factory.meta.moduleName = `my-app/${name}.hbs`;
} else if (typeof factory.__meta === 'object') {
// Ember 3.13+
factory.__meta.moduleName = `my-app/${name}.hbs`;
}

this.owner.register(`template:${name}`, factory);
}

function isVisible(elem) {
Expand Down Expand Up @@ -85,6 +92,7 @@ function setupApp() {
setTemplate.call(this, 'simple', hbs`Simple {{test-foo class="simple-component"}}`);
setTemplate.call(this, 'comments/index', hbs`{{#each}}{{this}}{{/each}}`);
setTemplate.call(this, 'posts', hbs`Posts`);
setTemplate.call(this, 'components/test-foo', hbs`test-foo`);
}

module('Ember Debug - View', function(hooks) {
Expand Down Expand Up @@ -150,6 +158,7 @@ module('Ember Debug - View', function(hooks) {
assert.equal(simple.children.length, 1, 'Components are shown.');
let component = simple.children[0];
assert.equal(component.value.viewClass, 'App.TestFooComponent');
assert.equal(component.value.template, 'my-app/components/test-foo');
});

skip('Highlighting Views on hover', async function t(assert) {
Expand Down

0 comments on commit bc6809c

Please sign in to comment.