Skip to content

Commit 4ff637c

Browse files
Use WeakMap for capturedArgs instead of symbol-keyed property on component
Co-authored-by: NullVoxPopuli <[email protected]>
1 parent eb18512 commit 4ff637c

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

packages/@ember/-internals/glimmer/lib/component-managers/curly.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,16 @@ import { processComponentArgs } from '../utils/process-args';
5656
export const ARGS = Symbol('ARGS');
5757
export const HAS_BLOCK = Symbol('HAS_BLOCK');
5858

59+
// WeakMap to store capturedArgs for each component instance, avoiding
60+
// symbol-keyed properties on the instance itself.
61+
const COMPONENT_ARGS_MAP = new WeakMap<object, CapturedArguments['named']>();
62+
63+
export function getComponentCapturedArgs(
64+
component: object
65+
): CapturedArguments['named'] | undefined {
66+
return COMPONENT_ARGS_MAP.get(component);
67+
}
68+
5969
export const DIRTY_TAG = Symbol('DIRTY_TAG');
6070
export const IS_DISPATCHING_ATTRS = Symbol('IS_DISPATCHING_ATTRS');
6171
export const BOUNDS = Symbol('BOUNDS');
@@ -286,6 +296,11 @@ export default class CurlyComponentManager
286296
beginUntrackFrame();
287297
let component = ComponentClass.create(props);
288298

299+
// Store capturedArgs in a WeakMap keyed by the component instance so that
300+
// PROPERTY_DID_CHANGE can look them up without requiring symbol-keyed
301+
// properties on the instance.
302+
COMPONENT_ARGS_MAP.set(component, capturedArgs);
303+
289304
let finalizer = _instrumentStart('render.component', initialRenderInstrumentDetails, component);
290305

291306
// We become the new parentView for downstream components, so save our

packages/@ember/-internals/glimmer/lib/component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ import type { DirtyableTag } from '@glimmer/validator';
2828
import { createTag, dirtyTag } from '@glimmer/validator';
2929
import type { SimpleElement } from '@simple-dom/interface';
3030
import {
31-
ARGS,
3231
BOUNDS,
3332
CURLY_COMPONENT_MANAGER,
3433
DIRTY_TAG,
3534
IS_DISPATCHING_ATTRS,
35+
getComponentCapturedArgs,
3636
} from './component-managers/curly';
3737
import { hasDOM } from '@ember/-internals/browser-environment';
3838

@@ -1038,7 +1038,7 @@ class Component<S = unknown>
10381038
return;
10391039
}
10401040

1041-
let args = (this as any)[ARGS];
1041+
let args = getComponentCapturedArgs(this);
10421042
let reference = args !== undefined ? args[key] : undefined;
10431043

10441044
if (reference !== undefined && isUpdatableRef(reference)) {

0 commit comments

Comments
 (0)