Skip to content

Commit

Permalink
Preserve case of css variables added by plugins
Browse files Browse the repository at this point in the history
We upgrade postcss-js to v4 to fix this
  • Loading branch information
thecrypticace committed Jan 5, 2022
1 parent 30ea5b1 commit e3fe4dd
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 13 deletions.
25 changes: 13 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -79,7 +79,7 @@
"is-glob": "^4.0.3",
"normalize-path": "^3.0.0",
"object-hash": "^2.2.0",
"postcss-js": "^3.0.3",
"postcss-js": "^4.0.0",
"postcss-load-config": "^3.1.0",
"postcss-nested": "5.0.6",
"postcss-selector-parser": "^6.0.7",
Expand Down
19 changes: 19 additions & 0 deletions tests/custom-plugins.test.js
Expand Up @@ -1892,3 +1892,22 @@ test('animation values are joined when retrieved using the theme function', () =
`)
})
})

test('custom properties are not converted to kebab-case when added to base layer', () => {
let config = {
content: [],
plugins: [
function ({ addBase }) {
addBase({
":root": {
"--colors-primaryThing-500": "0, 0, 255",
},
});
},
],
}

return run('@tailwind base', config).then((result) => {
expect(result.css).toContain(`--colors-primaryThing-500: 0, 0, 255;`)
})
})
15 changes: 15 additions & 0 deletions tests/parseObjectStyles.test.js
@@ -1,5 +1,6 @@
import parseObjectStyles from '../src/util/parseObjectStyles'
import postcss from 'postcss'
import postcssJs from 'postcss-js'

function css(nodes) {
return postcss.root({ nodes }).toString()
Expand Down Expand Up @@ -300,3 +301,17 @@ test('it can parse an array of styles', () => {
}
`)
})

test('custom properties preserve their case', () => {
const result = parseObjectStyles({
':root': {
"--colors-aColor-500": "0",
},
})

expect(css(result)).toMatchCss(`
:root {
--colors-aColor-500: 0;
}
`)
})

0 comments on commit e3fe4dd

Please sign in to comment.