Skip to content

Commit

Permalink
add current element to in-element
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklx authored and NullVoxPopuli committed Oct 19, 2024
1 parent 34888e9 commit 22d9e4b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class DebugRenderTreeTest extends RenderTest {
type: 'keyword',
name: 'in-element',
args: { positional: [this.element.firstChild], named: {} },
instance: (instance: GlimmerishComponent) => instance === null,
instance: (instance: any) => instance === null,
template: null,
bounds: this.elementBounds(this.element.firstChild! as unknown as Element),
children: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface RenderNode {
args: CapturedArguments;
instance: unknown;
template?: string | undefined;
meta?: Record<string, any>;
}

export interface CapturedRenderNode {
Expand All @@ -26,6 +27,7 @@ export interface CapturedRenderNode {
args: Arguments;
instance: unknown;
template: string | null;
meta: Record<string, any> | null;
bounds: null | {
parentElement: SimpleElement;
firstNode: SimpleNode;
Expand Down
3 changes: 3 additions & 0 deletions packages/@glimmer/runtime/lib/compiled/opcodes/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ APPEND_OPCODES.add(Op.PushRemoteElement, (vm) => {
name: 'in-element',
args,
instance: null,
meta: {
parentElement: vm.elements().element,
},
});

registerDestructor(block, () => {
Expand Down
14 changes: 12 additions & 2 deletions packages/@glimmer/runtime/lib/debug-render-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,21 @@ export default class DebugRenderTreeImpl<TBucket extends object>

private captureNode(id: string, state: TBucket): CapturedRenderNode {
let node = this.nodeFor(state);
let { type, name, args, instance, refs } = node;
let { type, name, args, instance, refs, meta = null } = node;
let template = this.captureTemplate(node);
let bounds = this.captureBounds(node);
let children = this.captureRefs(refs);
return { id, type, name, args: reifyArgsDebug(args), instance, template, bounds, children };
return {
id,
type,
name,
args: reifyArgsDebug(args),
instance,
template,
bounds,
children,
meta,
};
}

private captureTemplate({ template }: InternalRenderNode<TBucket>): Nullable<string> {
Expand Down

0 comments on commit 22d9e4b

Please sign in to comment.