diff --git a/package.json b/package.json index 931d656..bbb95e5 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "classnames": "^2.3.1", "csstype": "^3.1.3", "rc-util": "^5.35.0", - "stylis": "^4.0.13" + "stylis": "^4.3.3" }, "devDependencies": { "@ctrl/tinycolor": "^3.4.0", diff --git a/tests/index.spec.tsx b/tests/index.spec.tsx index bbf663e..028b882 100644 --- a/tests/index.spec.tsx +++ b/tests/index.spec.tsx @@ -777,4 +777,38 @@ describe('csssinjs', () => { }); }); }); + + it('hash & nest style', () => { + const genHashStyle = (): CSSInterpolation => ({ + '&': { + a: { + color: 'red', + }, + }, + }); + + const Holder = () => { + const [token, hashId] = useCacheToken(theme, [], { + salt: 'test', + }); + + useStyleRegister({ theme, token, hashId, path: ['holder'] }, () => [ + genHashStyle(), + ]); + + return
; + }; + + const { unmount } = render(); + + const styles = Array.from(document.head.querySelectorAll('style')); + expect(styles).toHaveLength(1); + + const style = styles[0]; + expect(style.innerHTML).toContain( + ':where(.css-dev-only-do-not-override-1ldpa3u) a{color:red;}', + ); + + unmount(); + }); });