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

Fix template name #1085

Merged
merged 1 commit into from
Nov 14, 2019
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
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