Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
small refactor: only check for -- once
  • Loading branch information
RobinMalfait committed Jan 31, 2025
commit be267f61c81d252cd22f562c317a15fb019846eb
17 changes: 9 additions & 8 deletions packages/tailwindcss/src/compat/plugin-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,17 +499,18 @@ export function objectToAst(rules: CssInJs | CssInJs[]): AstNode[] {

for (let [name, value] of entries) {
if (typeof value !== 'object') {
if (!name.startsWith('--') && value === '@slot') {
ast.push(rule(name, [atRule('@slot')]))
} else {
if (!name.startsWith('--')) {
// Convert camelCase to kebab-case:
// https://github.com/postcss/postcss-js/blob/b3db658b932b42f6ac14ca0b1d50f50c4569805b/parser.js#L30-L35
name = name.replace(/([A-Z])/g, '-$1').toLowerCase()
if (!name.startsWith('--')) {
if (value === '@slot') {
ast.push(rule(name, [atRule('@slot')]))
continue
}

ast.push(decl(name, String(value)))
// Convert camelCase to kebab-case:
// https://github.com/postcss/postcss-js/blob/b3db658b932b42f6ac14ca0b1d50f50c4569805b/parser.js#L30-L35
name = name.replace(/([A-Z])/g, '-$1').toLowerCase()
}

ast.push(decl(name, String(value)))
} else if (Array.isArray(value)) {
for (let item of value) {
if (typeof item === 'string') {
Expand Down