Skip to content
Merged
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
16 changes: 14 additions & 2 deletions packages/@ember/-internals/glimmer/lib/component-managers/curly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,15 @@ import {
import ComponentStateBucket from '../utils/curly-component-state-bucket';
import { processComponentArgs } from '../utils/process-args';

export const ARGS = Symbol('ARGS');
export const HAS_BLOCK = Symbol('HAS_BLOCK');
// WeakMap to store capturedArgs for each component instance, avoiding
// symbol-keyed properties on the instance itself.
const COMPONENT_ARGS_MAP = new WeakMap<object, CapturedArguments['named']>();

export function getComponentCapturedArgs(
component: object
): CapturedArguments['named'] | undefined {
return COMPONENT_ARGS_MAP.get(component);
}

export const DIRTY_TAG = Symbol('DIRTY_TAG');
export const IS_DISPATCHING_ATTRS = Symbol('IS_DISPATCHING_ATTRS');
Expand Down Expand Up @@ -286,6 +293,11 @@ export default class CurlyComponentManager
beginUntrackFrame();
let component = ComponentClass.create(props);

// Store capturedArgs in a WeakMap keyed by the component instance so that
// PROPERTY_DID_CHANGE can look them up without requiring symbol-keyed
// properties on the instance.
COMPONENT_ARGS_MAP.set(component, capturedArgs);

let finalizer = _instrumentStart('render.component', initialRenderInstrumentDetails, component);

// We become the new parentView for downstream components, so save our
Expand Down
4 changes: 2 additions & 2 deletions packages/@ember/-internals/glimmer/lib/component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ import type { DirtyableTag } from '@glimmer/validator';
import { createTag, dirtyTag } from '@glimmer/validator';
import type { SimpleElement } from '@simple-dom/interface';
import {
ARGS,
BOUNDS,
CURLY_COMPONENT_MANAGER,
DIRTY_TAG,
IS_DISPATCHING_ATTRS,
getComponentCapturedArgs,
} from './component-managers/curly';
import { hasDOM } from '@ember/-internals/browser-environment';

Expand Down Expand Up @@ -1038,7 +1038,7 @@ class Component<S = unknown>
return;
}

let args = (this as any)[ARGS];
let args = getComponentCapturedArgs(this);
let reference = args !== undefined ? args[key] : undefined;

if (reference !== undefined && isUpdatableRef(reference)) {
Expand Down
Loading