Skip to content

Commit

Permalink
chore: update stylis to avoid leading '&' generate invalid css (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
magicdawn authored Oct 27, 2024
1 parent be4e05b commit eabc24e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"classnames": "^2.3.1",
"csstype": "^3.1.3",
"rc-util": "^5.35.0",
"stylis": "^4.3.3"
"stylis": "^4.3.4"
},
"devDependencies": {
"@ctrl/tinycolor": "^3.4.0",
Expand Down
21 changes: 21 additions & 0 deletions tests/util.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,25 @@ describe('util', () => {
const ret2 = memoResult(() => ({ ...obj1, ...obj2 }), [obj1, obj2]);
expect(memoResult(() => ({ ...obj1, ...obj2 }), [obj1, obj2])).toBe(ret2);
});

describe('normalizeStyle', () => {
it('with leading &', () => {
const [str] = parseStyle(
{
'&.btn-variant-outline,&.btn-variant-dashed': {
color: 'red',
},
},
{ hashId: 'hashed' },
);
const normalized = normalizeStyle(str);

expect(str).toEqual(
'.hashed&.btn-variant-outline,.hashed&.btn-variant-dashed{color:red;}',
);
expect(normalized).toEqual(
'.hashed.btn-variant-outline,.hashed.btn-variant-dashed{color:red;}',
);
});
});
});

0 comments on commit eabc24e

Please sign in to comment.