Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,51 @@ class DebugRenderTreeTest extends RenderTest {
]);
}

@test 'strict-mode template-only invocation names'() {
const Greeter = defComponent('Hello');
const Actual = defComponent('Hi');

const Root = defComponent(`<Greeter /><Alias />`, {
scope: { Greeter, Alias: Actual },
emit: { moduleName: 'root.hbs' },
});

this.renderComponent(Root);

const element = this.delegate.getInitialElement();

this.assertRenderTree([
{
type: 'component',
name: '{ROOT}',
args: { positional: [], named: {} },
instance: null,
template: 'root.hbs',
bounds: this.elementBounds(element),
children: [
{
type: 'component',
name: 'Greeter',
args: { positional: [], named: {} },
instance: null,
template: '(unknown template module)',
bounds: this.nodeBounds(element.firstChild),
children: [],
},
{
type: 'component',
name: 'Alias',
args: { positional: [], named: {} },
instance: null,
template: '(unknown template module)',
bounds: this.nodeBounds(element.lastChild),
children: [],
},
],
},
]);
}

@test 'strict-mode modifiers'() {
const state = trackedObj({ showSecond: false });

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,14 @@ export function resolveComponent(
expr[1]
];

let invocationName = lexical?.at(expr[1]);

then(
constants.component(
definition as object,
expect(owner, 'BUG: expected owner when resolving component definition'),
false,
lexical?.at(expr[1])
invocationName
)
);
} else {
Expand Down Expand Up @@ -287,11 +289,13 @@ export function resolveComponentOrHelper(
expr[1]
];

let invocationName = lexical?.at(expr[1]);

let component = constants.component(
definition as object,
expect(owner, 'BUG: expected owner when resolving component definition'),
true,
lexical?.at(expr[1])
invocationName
);

if (component !== null) {
Expand Down
10 changes: 8 additions & 2 deletions packages/@glimmer/runtime/lib/debug-render-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,13 @@ export default class DebugRenderTreeImpl<TBucket extends object>

export function getDebugName(
definition: ComponentDefinition,
manager = definition.manager
manager = definition.manager,
invocationName?: string
): string {
return definition.resolvedName ?? definition.debugName ?? manager.getDebugName(definition.state);
return (
invocationName ??
definition.resolvedName ??
definition.debugName ??
manager.getDebugName(definition.state)
);
}