From 35a5e8cb64fde0b8611ea1968ad25e5d2dafe544 Mon Sep 17 00:00:00 2001 From: Jordan Pittman Date: Fri, 31 Jan 2025 09:53:02 -0500 Subject: [PATCH] Discard invalid declarations when parsing CSS (#16093) I discovered this when triaging an error someone had on Tailwind Play. 1. When we see a `;` we often assume a valid declaration precedes it but that may not be the case 2. When we see the name of a custom property we assume everything that follows will be a valid declaration but that is not necessarily the case 3. A bare identifier inside of a rule is treated as a declaration which is not the case This PR fixes all three of these by ignoring these invalid cases. Though some should probably be turned into errors. --------- Co-authored-by: Robin Malfait --- CHANGELOG.md | 1 + packages/tailwindcss/src/css-parser.test.ts | 56 +++++++++++++++++++++ packages/tailwindcss/src/css-parser.ts | 18 ++++++- 3 files changed, 73 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff0ec536b880..114412e42d3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Vite: Transform `