From 54607f61560c82a698b59229911eae402cccc62a Mon Sep 17 00:00:00 2001 From: magicdawn Date: Sun, 27 Oct 2024 19:48:09 +0800 Subject: [PATCH] chore: update stylis to avoid leading '&' generate invalid css --- package.json | 2 +- tests/util.spec.tsx | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index e1bc01b..a5b279c 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/tests/util.spec.tsx b/tests/util.spec.tsx index 1b9f0da..d9faffc 100644 --- a/tests/util.spec.tsx +++ b/tests/util.spec.tsx @@ -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;}', + ); + }); + }); });