Skip to content

Commit 3bf6348

Browse files
committed
split @apply values by spaces, tabs and newlines
Fixes: tailwindlabs#2222
1 parent c16bf20 commit 3bf6348

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

__tests__/applyComplexClasses.test.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,53 @@ test('it copies class declarations into itself', () => {
4747
})
4848
})
4949

50+
test('apply values can contain tabs', () => {
51+
const input = `
52+
.a {
53+
@apply p-4\tm-4;
54+
}
55+
`
56+
57+
const expected = `
58+
.a {
59+
margin: 1rem;
60+
padding: 1rem;
61+
}
62+
`
63+
64+
expect.assertions(2)
65+
66+
return run(input).then(result => {
67+
expect(result.css).toMatchCss(expected)
68+
expect(result.warnings().length).toBe(0)
69+
})
70+
})
71+
72+
test('apply values can contain newlines', () => {
73+
const input = `
74+
.a {
75+
@apply p-4 m-4
76+
flex flex-col;
77+
}
78+
`
79+
80+
const expected = `
81+
.a {
82+
display: flex;
83+
flex-direction: column;
84+
margin: 1rem;
85+
padding: 1rem;
86+
}
87+
`
88+
89+
expect.assertions(2)
90+
91+
return run(input).then(result => {
92+
expect(result.css).toMatchCss(expected)
93+
expect(result.warnings().length).toBe(0)
94+
})
95+
})
96+
5097
test('selectors with invalid characters do not need to be manually escaped', () => {
5198
const input = `
5299
.a\\:1\\/2 { color: red; }

src/flagged/applyComplexClasses.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ function processApplyAtRules(css, lookupTree, config) {
200200
importantEntries,
201201
applyUtilityNames,
202202
important = importantEntries.length > 0,
203-
] = _.partition(applyRule.params.split(' '), n => n === '!important')
203+
] = _.partition(applyRule.params.split(/[\s\t\n]+/g), n => n === '!important')
204204

205205
const currentUtilityNames = extractUtilityNames(rule.selector)
206206

0 commit comments

Comments
 (0)