From aba7ee5a1db35f1b0901f900a3c097eddca1973d Mon Sep 17 00:00:00 2001 From: Luke Bennett Date: Thu, 17 Sep 2026 18:45:38 +1000 Subject: [PATCH] Rewrite sprinkle prop filters to assign kept keys (#608) omitUnsupportedSprinklesProps and retainSprinklesProps now allocate an empty object and copy only retained keys, instead of spreading then deleting. That avoids a full copy plus delete on Box and layout render paths, which is easier on V8 object shapes. Co-authored-by: Cursor Agent --- packages/@luke-ui/react/src/core/box/box.tsx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/@luke-ui/react/src/core/box/box.tsx b/packages/@luke-ui/react/src/core/box/box.tsx index e3249bb3..85131de6 100644 --- a/packages/@luke-ui/react/src/core/box/box.tsx +++ b/packages/@luke-ui/react/src/core/box/box.tsx @@ -68,25 +68,25 @@ export function omitUnsupportedSprinklesProps( props: Props, supportedProperties: ReadonlySet, ): Props { - const sprinklesProps = { ...props }; + const nextProps: Record = {}; - for (const key of Reflect.ownKeys(sprinklesProps)) { - if (sprinklesProperties.has(key) && !supportedProperties.has(key)) { - Reflect.deleteProperty(sprinklesProps, key); + for (const key of Reflect.ownKeys(props)) { + if (!sprinklesProperties.has(key) || supportedProperties.has(key)) { + nextProps[key] = props[key as keyof Props]; } } - return sprinklesProps; + return nextProps as Props; } function retainSprinklesProps(props: Props): Props { - const sprinklesProps = { ...props }; + const nextProps: Record = {}; - for (const key of Reflect.ownKeys(sprinklesProps)) { - if (!sprinklesProperties.has(key)) { - Reflect.deleteProperty(sprinklesProps, key); + for (const key of Reflect.ownKeys(props)) { + if (sprinklesProperties.has(key)) { + nextProps[key] = props[key as keyof Props]; } } - return sprinklesProps; + return nextProps as Props; } -- 2.51.2