Skip to content

Commit

Permalink
fix: prevent overwriting cached objects in style()
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredLunde committed Oct 4, 2021
1 parent 6113157 commit 827acc9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,19 @@ export function createStyles<
// style('text', {})
function style(...args: StyleArguments<Extract<keyof T, string>>) {
const numArgs = args.length;
const sheet = styleMap.default
let sheet = styleMap.default
? compileStyles(styleMap.default, tokens[currentTheme] as V)
: {};

if (numArgs === 1 && typeof args[0] === "string") {
Object.assign(
sheet,
compileStyles(styleMap[args[0]], tokens[currentTheme] as V)
);
sheet = {
...sheet,
...compileStyles(styleMap[args[0]], tokens[currentTheme] as V),
};
} else if (numArgs > 0) {
let i = 0;
let arg;
sheet = { ...sheet };

for (; i < numArgs; i++) {
arg = args[i];
Expand Down

0 comments on commit 827acc9

Please sign in to comment.