From c2f25b46e7ab2a1a1d4a442f36b35549613c7f48 Mon Sep 17 00:00:00 2001 From: Patrick Pircher Date: Sat, 9 Mar 2024 08:44:08 +0100 Subject: [PATCH] add current element to in-element --- .../test/debug-render-tree-test.ts | 2 +- .../interfaces/lib/runtime/debug-render-tree.d.ts | 2 ++ .../@glimmer/runtime/lib/compiled/opcodes/dom.ts | 3 +++ packages/@glimmer/runtime/lib/debug-render-tree.ts | 14 ++++++++++++-- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/@glimmer-workspace/integration-tests/test/debug-render-tree-test.ts b/packages/@glimmer-workspace/integration-tests/test/debug-render-tree-test.ts index 6c8dbf24a0..4d0fdc544e 100644 --- a/packages/@glimmer-workspace/integration-tests/test/debug-render-tree-test.ts +++ b/packages/@glimmer-workspace/integration-tests/test/debug-render-tree-test.ts @@ -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: [ diff --git a/packages/@glimmer/interfaces/lib/runtime/debug-render-tree.d.ts b/packages/@glimmer/interfaces/lib/runtime/debug-render-tree.d.ts index e3a7aafd75..a9504c67d7 100644 --- a/packages/@glimmer/interfaces/lib/runtime/debug-render-tree.d.ts +++ b/packages/@glimmer/interfaces/lib/runtime/debug-render-tree.d.ts @@ -17,6 +17,7 @@ export interface RenderNode { args: CapturedArguments; instance: unknown; template?: string | undefined; + meta?: Record; } export interface CapturedRenderNode { @@ -26,6 +27,7 @@ export interface CapturedRenderNode { args: Arguments; instance: unknown; template: string | null; + meta: Record | null; bounds: null | { parentElement: SimpleElement; firstNode: SimpleNode; diff --git a/packages/@glimmer/runtime/lib/compiled/opcodes/dom.ts b/packages/@glimmer/runtime/lib/compiled/opcodes/dom.ts index f575240eb5..b11a9d4017 100644 --- a/packages/@glimmer/runtime/lib/compiled/opcodes/dom.ts +++ b/packages/@glimmer/runtime/lib/compiled/opcodes/dom.ts @@ -87,6 +87,9 @@ APPEND_OPCODES.add(Op.PushRemoteElement, (vm) => { name: 'in-element', args, instance: null, + meta: { + parentElement: vm.elements().element, + }, }); registerDestructor(block, () => { diff --git a/packages/@glimmer/runtime/lib/debug-render-tree.ts b/packages/@glimmer/runtime/lib/debug-render-tree.ts index 8d110e8284..be9ab516a3 100644 --- a/packages/@glimmer/runtime/lib/debug-render-tree.ts +++ b/packages/@glimmer/runtime/lib/debug-render-tree.ts @@ -177,11 +177,21 @@ export default class DebugRenderTreeImpl 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): Nullable {