Skip to content

Commit 9945904

Browse files
authored
6.x bugfixes (#5746)
* fix: adjust speedy flag Fixes #5738 * test(rsc): reset identifiers between tests to stabilize class hashes * fix: various bugs
1 parent f7cddb5 commit 9945904

41 files changed

Lines changed: 337 additions & 149 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"styled-components": patch
3+
---
4+
5+
Restore TypeScript prop autocomplete inside the JSX of a styled component once the first attribute is typed.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"styled-components": patch
3+
---
4+
5+
Apply all chain levels' styles when an extended styled component renders with the `as` prop under Preact's `react-compat`.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"styled-components": patch
3+
---
4+
5+
Respect a custom `toString` on plain value objects (e.g. design tokens) when interpolated into a styled component, rather than walking the object's keys as CSS declarations.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"styled-components": patch
3+
---
4+
5+
Fix a TypeScript error when wrapping a component whose props include an `as` prop with a non-string type (such as Next.js `Link`'s `as?: Url`). The styled-components `as` and `forwardedAs` props now consistently override the wrapped component's same-named props instead of colliding with them.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"styled-components": patch
3+
---
4+
5+
Restore reliable styling in production browser bundles built without a runtime `process` global.

‎packages/styled-components/docs/faq.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default function Page() {
2222
}
2323
```
2424

25-
RSC environments are detected automatically—no configuration required. Styles are emitted alongside each component's markup and deduplicated per render.
25+
RSC environments are detected automatically - no configuration required. Styles are emitted alongside each component's markup and deduplicated per render.
2626

2727
**For Next.js App Router (SSR Style Extraction):**
2828

@@ -108,11 +108,11 @@ export default async function Page() {
108108
}
109109
```
110110

111-
This generates static CSS with a sensible default—no attribute needed for the base case.
111+
This generates static CSS with a sensible default - no attribute needed for the base case.
112112

113113
2. **Use CSS custom properties for dynamic values:**
114114

115-
CSS variables can be set via inline `style` and cascade to all DOM children—perfect for RSC theming:
115+
CSS variables can be set via inline `style` and cascade to all DOM children - perfect for RSC theming:
116116

117117
```tsx
118118
const Container = styled.div``;

‎packages/styled-components/src/bench/rsc.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* and keyframe handling.
99
*/
1010

11-
// Mock React.cache — scoped per render via manual clear
11+
// Mock React.cache - scoped per render via manual clear
1212
const mockCacheStore = new Map<Function, any>();
1313

1414
jest.mock('react', () => {

‎packages/styled-components/src/constants.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const DISABLE_SPEEDY = Boolean(
4242
readSpeedyFlag('SC_DISABLE_SPEEDY') ??
4343
(typeof process !== 'undefined' && typeof process.env !== 'undefined'
4444
? process.env.NODE_ENV !== 'production'
45-
: true))
45+
: false))
4646
);
4747

4848
export const KEYFRAMES_ID_PREFIX = 'sc-keyframes-';

‎packages/styled-components/src/constructors/createGlobalStyle.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export default function createGlobalStyle<Props extends object>(
169169
}
170170
}
171171

172-
// Clean up server instance cache — no useLayoutEffect cleanup runs on the
172+
// Clean up server instance cache - no useLayoutEffect cleanup runs on the
173173
// server, so instanceRules would grow unboundedly across SSR requests.
174174
if (__SERVER__ || ssc.styleSheet.server) {
175175
globalStyle.instanceRules.delete(instance);

‎packages/styled-components/src/constructors/createTheme.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ type ThemeContract<T> = CSSVarTheme<T> & {
5252
* Optionally pass a target element to read scoped variables from
5353
* (defaults to `document.documentElement`).
5454
*
55-
* Client-only — throws if called on the server.
55+
* Client-only - throws if called on the server.
5656
*/
5757
resolve(el?: Element): T;
5858
};
5959

60-
/** Shared recursive traversal — calls `leafFn` for each leaf, recurses for objects. */
60+
/** Shared recursive traversal - calls `leafFn` for each leaf, recurses for objects. */
6161
function walkTheme(
6262
obj: Record<string, any>,
6363
varPrefix: string,
@@ -124,7 +124,7 @@ function resolveVars<T extends Record<string, any>>(
124124

125125
/**
126126
* Emit CSS var declarations by walking `shape` for structure and reading
127-
* values from `theme`. This avoids hardcoded skip lists — only keys
127+
* values from `theme`. This avoids hardcoded skip lists - only keys
128128
* present in the original theme shape are traversed.
129129
*/
130130
function emitVarDeclarations(
@@ -178,7 +178,7 @@ interface CreateThemeOptions {
178178
*
179179
* Returns an object with the same shape as the input theme, but every leaf value
180180
* is a `var(--prefix-*, fallback)` CSS string. Use these in styled component
181-
* templates — they work in both client and RSC contexts.
181+
* templates - they work in both client and RSC contexts.
182182
*
183183
* Mount the returned `GlobalStyle` component inside your `ThemeProvider` to emit
184184
* the CSS variables. When the theme changes (e.g. light → dark), the variables

0 commit comments

Comments
 (0)