Skip to content

Commit

Permalink
Quick fix for incorrect arbitrary properties when using URLs (#7252)
Browse files Browse the repository at this point in the history
* quick fix for incorrect arbitrary properties

Turns out that using links like [https://example.com] causes arbitrary
properties to generate invalid css.
This is a very dirty quick fix for this specific case, so we have to fix
this properly!

* update changelog
  • Loading branch information
RobinMalfait authored Jan 28, 2022
1 parent 0bdc90d commit 39193c1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Fix `@apply` order regression (in `addComponents`, `addUtilities`, ...) ([#7232](https://github.com/tailwindlabs/tailwindcss/pull/7232))
- Quick fix for incorrect arbitrary properties when using URLs ([#7252](https://github.com/tailwindlabs/tailwindcss/pull/7252))

## [3.0.17] - 2022-01-26

Expand Down
3 changes: 2 additions & 1 deletion src/lib/generateRules.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ function parseRules(rule, cache, options = {}) {
const IS_VALID_PROPERTY_NAME = /^[a-z_-]/

function isValidPropName(name) {
return IS_VALID_PROPERTY_NAME.test(name)
// TODO: properly fix this!
return IS_VALID_PROPERTY_NAME.test(name) && !name.startsWith('http')
}

function isParsableCssValue(property, value) {
Expand Down
15 changes: 15 additions & 0 deletions tests/arbitrary-properties.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,3 +347,18 @@ it('should be possible to read theme values in arbitrary properties (with quotes
`)
})
})

it('should not generate invalid CSS', () => {
let config = {
content: [
{
raw: html`<div class="[https://en.wikipedia.org/wiki]"></div>`,
},
],
corePlugins: { preflight: false },
}

return run('@tailwind utilities', config).then((result) => {
return expect(result.css).toMatchFormattedCss(css``)
})
})

0 comments on commit 39193c1

Please sign in to comment.