Skip to content

Commit 1e8a70b

Browse files
committed
Promote pluginVariants from experiment to feature
1 parent 58f10b6 commit 1e8a70b

File tree

2 files changed

+7
-48
lines changed

2 files changed

+7
-48
lines changed

__tests__/variantsAtRule.test.js

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -189,36 +189,7 @@ test('it wraps the output in a responsive at-rule if responsive is included as a
189189
})
190190
})
191191

192-
test('variants are generated in a fixed order regardless of the order specified by default', () => {
193-
const input = `
194-
@variants focus, active, hover, group-hover {
195-
.banana { color: yellow; }
196-
.chocolate { color: brown; }
197-
}
198-
`
199-
200-
const output = `
201-
.banana { color: yellow; }
202-
.chocolate { color: brown; }
203-
.group:hover .group-hover\\:banana { color: yellow; }
204-
.group:hover .group-hover\\:chocolate { color: brown; }
205-
.hover\\:banana:hover { color: yellow; }
206-
.hover\\:chocolate:hover { color: brown; }
207-
.focus\\:banana:focus { color: yellow; }
208-
.focus\\:chocolate:focus { color: brown; }
209-
.active\\:banana:active { color: yellow; }
210-
.active\\:chocolate:active { color: brown; }
211-
`
212-
213-
return run(input, {
214-
...config,
215-
}).then(result => {
216-
expect(result.css).toMatchCss(output)
217-
expect(result.warnings().length).toBe(0)
218-
})
219-
})
220-
221-
test('if plugin variants are enabled, variants are generated in the order specified', () => {
192+
test('variants are generated in the order specified', () => {
222193
const input = `
223194
@variants focus, active, hover {
224195
.banana { color: yellow; }
@@ -239,14 +210,13 @@ test('if plugin variants are enabled, variants are generated in the order specif
239210

240211
return run(input, {
241212
...config,
242-
experiments: { pluginVariants: true },
243213
}).then(result => {
244214
expect(result.css).toMatchCss(output)
245215
expect(result.warnings().length).toBe(0)
246216
})
247217
})
248218

249-
test('if plugin variants are enabled, plugin variants can modify rules using the raw PostCSS API', () => {
219+
test('plugin variants can modify rules using the raw PostCSS API', () => {
250220
const input = `
251221
@variants important {
252222
.banana { color: yellow; }
@@ -263,7 +233,6 @@ test('if plugin variants are enabled, plugin variants can modify rules using the
263233

264234
return run(input, {
265235
...config,
266-
experiments: { pluginVariants: true },
267236
plugins: [
268237
...config.plugins,
269238
function({ addVariant }) {
@@ -283,7 +252,7 @@ test('if plugin variants are enabled, plugin variants can modify rules using the
283252
})
284253
})
285254

286-
test('if plugin variants are enabled, plugin variants can modify selectors with a simplified API', () => {
255+
test('plugin variants can modify selectors with a simplified API', () => {
287256
const input = `
288257
@variants first-child {
289258
.banana { color: yellow; }
@@ -300,7 +269,6 @@ test('if plugin variants are enabled, plugin variants can modify selectors with
300269

301270
return run(input, {
302271
...config,
303-
experiments: { pluginVariants: true },
304272
plugins: [
305273
...config.plugins,
306274
function({ addVariant }) {
@@ -317,7 +285,7 @@ test('if plugin variants are enabled, plugin variants can modify selectors with
317285
})
318286
})
319287

320-
test('if plugin variants are enabled, plugin variants can wrap rules in another at-rule using the raw PostCSS API', () => {
288+
test('plugin variants can wrap rules in another at-rule using the raw PostCSS API', () => {
321289
const input = `
322290
@variants supports-grid {
323291
.banana { color: yellow; }
@@ -336,7 +304,6 @@ test('if plugin variants are enabled, plugin variants can wrap rules in another
336304

337305
return run(input, {
338306
...config,
339-
experiments: { pluginVariants: true },
340307
plugins: [
341308
...config.plugins,
342309
function({ addVariant }) {

src/lib/substituteVariantsAtRules.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,17 +40,9 @@ export default function(config, { variantGenerators: pluginVariantGenerators })
4040

4141
atRule.before(atRule.clone().nodes)
4242

43-
if (_.get(config, 'experiments.pluginVariants', false)) {
44-
_.forEach(_.without(variants, 'responsive'), variant => {
45-
variantGenerators[variant](atRule, config)
46-
})
47-
} else {
48-
_.forEach(['group-hover', 'hover', 'focus-within', 'focus', 'active'], variant => {
49-
if (variants.includes(variant)) {
50-
variantGenerators[variant](atRule, config)
51-
}
52-
})
53-
}
43+
_.forEach(_.without(variants, 'responsive'), variant => {
44+
variantGenerators[variant](atRule, config)
45+
})
5446

5547
atRule.remove()
5648
})

0 commit comments

Comments
 (0)