Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklx authored and NullVoxPopuli committed Oct 19, 2024
1 parent 01399dd commit d02dedf
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export class TestModifierManager
return tag;
}

getDebugName(definition?: object) {
return (definition as any).instance.constructor.name || '<unknown>';
getDebugName({ Klass }: TestModifierDefinitionState) {
return Klass?.name || '<unknown>';
}

getDebugInstance({ instance }: TestModifier) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export interface InternalModifierManager<
// the modifier's update hooks need to be called (if at all).
getTag(modifier: TModifierInstanceState): UpdatableTag | null;

getDebugName(modifier: TModifierInstanceState): string;
getDebugInstance(modifier: TModifierInstanceState): unknown;
getDebugName(Modifier: TModifierDefinitionState): string;
getDebugInstance(Modifier: TModifierInstanceState): unknown;

// At initial render, the modifier gets a chance to install itself on the
// element it is managing. It can also return a bucket of state that
Expand Down
2 changes: 1 addition & 1 deletion packages/@glimmer/interfaces/lib/managers/modifier.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ export interface ModifierManager<ModifierStateBucket> {
installModifier(instance: ModifierStateBucket, element: Element, args: Arguments): void;
updateModifier(instance: ModifierStateBucket, args: Arguments): void;
destroyModifier(instance: ModifierStateBucket, args: Arguments): void;
getDebugName?(definition?: object): string;
getDebugName?(factory?: unknown): string;
getDebugInstance?(instance: ModifierStateBucket): any;
}
5 changes: 2 additions & 3 deletions packages/@glimmer/manager/lib/public/modifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ export interface CustomModifierState<ModifierStateBucket> {
modifier: ModifierStateBucket;
delegate: ModifierManager<ModifierStateBucket>;
args: Arguments;
definition?: object;
}

/**
Expand Down Expand Up @@ -109,7 +108,6 @@ export class CustomModifierManager<O extends Owner, ModifierStateBucket>
element,
delegate,
args,
definition,
modifier,
};

Expand All @@ -118,7 +116,8 @@ export class CustomModifierManager<O extends Owner, ModifierStateBucket>
return state;
}

getDebugName({ delegate, definition }: CustomModifierState<ModifierStateBucket>) {
getDebugName(definition: object) {
const delegate = this.factory.prototype;
if (typeof delegate?.getDebugName === 'function') {
return delegate.getDebugName(definition);
}
Expand Down
4 changes: 2 additions & 2 deletions packages/@glimmer/runtime/lib/compiled/opcodes/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ export class ComponentElementOperations implements ElementOperations {
this.modifiers.push(modifier);

if (vm.env.debugRenderTree !== undefined) {
const { manager, state } = modifier;
const { manager, definition, state } = modifier;

// TODO: we need a stable object for the debugRenderTree as the key, add support for
// the case where the state is a primitive, or if in practice we always have/require
Expand All @@ -504,7 +504,7 @@ export class ComponentElementOperations implements ElementOperations {
}

let { element, constructing } = vm.elements();
let name = manager.getDebugName(state);
let name = manager.getDebugName(definition.state);
let instance = manager.getDebugInstance(state);

assert(constructing, `Expected a constructing element in addModifier`);
Expand Down
4 changes: 2 additions & 2 deletions packages/@glimmer/runtime/lib/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class TransactionImpl implements Transaction {
() => manager.install(state),
import.meta.env.DEV &&
`- While rendering:\n (instance of a \`${
definition.resolvedName || manager.getDebugName(state)
definition.resolvedName || manager.getDebugName(definition.state)
}\` modifier)`
);
updateTag(modifierTag, tag);
Expand All @@ -82,7 +82,7 @@ class TransactionImpl implements Transaction {
() => manager.update(state),
import.meta.env.DEV &&
`- While rendering:\n (instance of a \`${
definition.resolvedName || manager.getDebugName(state)
definition.resolvedName || manager.getDebugName(definition.state)
}\` modifier)`
);
updateTag(modifierTag, tag);
Expand Down

0 comments on commit d02dedf

Please sign in to comment.