Skip to content

Commit 39193c1

Browse files
authored
Quick fix for incorrect arbitrary properties when using URLs (#7252)
* 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
1 parent 0bdc90d commit 39193c1

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixed
1111

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

1415
## [3.0.17] - 2022-01-26
1516

src/lib/generateRules.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ function parseRules(rule, cache, options = {}) {
262262
const IS_VALID_PROPERTY_NAME = /^[a-z_-]/
263263

264264
function isValidPropName(name) {
265-
return IS_VALID_PROPERTY_NAME.test(name)
265+
// TODO: properly fix this!
266+
return IS_VALID_PROPERTY_NAME.test(name) && !name.startsWith('http')
266267
}
267268

268269
function isParsableCssValue(property, value) {

tests/arbitrary-properties.test.js

+15
Original file line numberDiff line numberDiff line change
@@ -347,3 +347,18 @@ it('should be possible to read theme values in arbitrary properties (with quotes
347347
`)
348348
})
349349
})
350+
351+
it('should not generate invalid CSS', () => {
352+
let config = {
353+
content: [
354+
{
355+
raw: html`<div class="[https://en.wikipedia.org/wiki]"></div>`,
356+
},
357+
],
358+
corePlugins: { preflight: false },
359+
}
360+
361+
return run('@tailwind utilities', config).then((result) => {
362+
return expect(result.css).toMatchFormattedCss(css``)
363+
})
364+
})

0 commit comments

Comments
 (0)