You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 7ff7002
Browse filesBrowse the repository at this point in the historyBrowse files
Fix: Line comments (`//`) in multiline CSS declarations no longer cause parsing errors (fixes #5613)
6
+
7
+
JS-style line comments (`//`) placed after multiline declarations like `calc()` were not being properly stripped, causing CSS parsing issues. Comments are now correctly removed anywhere in the CSS while preserving valid syntax.
Fix: Contain invalid CSS syntax to just the affected line
6
+
7
+
In styled-components v6, invalid CSS syntax (like unbalanced braces) could cause all subsequent styles to be ignored. This fix ensures that malformed CSS only affects the specific declaration, not subsequent valid styles.
8
+
9
+
**Example that now works:**
10
+
```tsx
11
+
const Circle =styled.div`
12
+
width: 100px;
13
+
line-height: ${() =>"14px}"}; // ⛔️ This malformed line is dropped
14
+
background-color: green; // ✅ Now preserved (was ignored in v6)
it('should preserve styles after a malformed declaration with unbalanced brace',()=>{
524
+
// This tests the fix for: https://github.com/styled-components/styled-components/issues/XXXX
525
+
// In v6, a syntax error like an extra `}` in a value would cause all subsequent styles to be ignored
526
+
constComp=styled.div`
527
+
width: 100px;
528
+
height: 100px;
529
+
border-radius: 50%;
530
+
line-height: ${'14px}"'}; /* Simulates: ${()=>'14px}'} - syntax error with extra } */
531
+
background-color: green;
532
+
`;
533
+
render(<Comp/>);
534
+
535
+
// The malformed line-height should be dropped, but background-color should still apply
0 commit comments