Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Refactor gradient implementation to work around [prettier/prettier#17058](https://github.com/prettier/prettier/issues/17058) ([#16072](https://github.com/tailwindlabs/tailwindcss/pull/16072))
- Vite: Ensure hot-reloading works with SolidStart setups ([#16052](https://github.com/tailwindlabs/tailwindcss/pull/16052))
- Vite: Fix a crash when starting the development server in SolidStart setups ([#16052](https://github.com/tailwindlabs/tailwindcss/pull/16052))
- Prevent camelCasing CSS custom properties added by JavaScript plugins ([#16103](https://github.com/tailwindlabs/tailwindcss/pull/16103))

## [4.0.1] - 2025-01-29

Expand Down
32 changes: 32 additions & 0 deletions packages/tailwindcss/src/compat/plugin-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1534,6 +1534,38 @@ describe('addBase', () => {
"
`)
})

test('does not modify CSS variables', async () => {
let input = css`
@plugin "my-plugin";
`

let compiler = await compile(input, {
loadModule: async () => ({
module: plugin(function ({ addBase }) {
addBase({
':root': {
'--PascalCase': '1',
'--camelCase': '1',
'--UPPERCASE': '1',
},
})
}),
base: '/root',
}),
})

expect(compiler.build([])).toMatchInlineSnapshot(`
"@layer base {
:root {
--PascalCase: 1;
--camelCase: 1;
--UPPERCASE: 1;
}
}
"
`)
})
})

describe('addVariant', () => {
Expand Down
13 changes: 8 additions & 5 deletions packages/tailwindcss/src/compat/plugin-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -499,15 +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('--')) {
if (value === '@slot') {
ast.push(rule(name, [atRule('@slot')]))
continue
}

// 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)))
}

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