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 committed Apr 4, 2024
1 parent f036320 commit e6ba8a7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 4 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
1 change: 0 additions & 1 deletion packages/@glimmer/syntax/test/plugin-node-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ test('deprecated program visitor', (assert) => {
return {
name: 'plugin',
visitor: {
// eslint-disable-next-line deprecation/deprecation
Program(node: AST.Program) {
assert.step(node.type);
},
Expand Down

0 comments on commit e6ba8a7

Please sign in to comment.