Skip to content

Commit a71fa69

Browse files
committed
fix(signals): bind createRoot's dispose instead of a helper closure
A bound disposeRootSelf holds only the owner, like the helper did, and is smaller than the original arrow (-2 B minified vs next instead of +18 B). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_018fTNh1FgQx2WTF5xoxwML1
1 parent 9dce7bb commit a71fa69

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

‎packages/signals/src/core/owner.ts‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -440,10 +440,8 @@ export function createRoot<T>(
440440
options?: { id?: string; transparent?: boolean }
441441
): T {
442442
const owner = createOwner(options);
443-
return runWithOwner(owner, () => init(disposer(owner)));
443+
// A bound function, not an arrow: an arrow would share this scope, which
444+
// holds `init`, so keeping `dispose` would keep `init` and all it closes
445+
// over alive (#4095).
446+
return runWithOwner(owner, () => init(disposeRootSelf.bind(owner, true)));
444447
}
445-
446-
// Built outside createRoot so the dispose function doesn't share its scope,
447-
// which holds `init`: keeping the dispose function would keep `init` and all
448-
// it closes over alive (#4095).
449-
const disposer = (owner: Root) => () => owner.dispose();

0 commit comments

Comments
 (0)