tailwindcss 0.0.0-insiders.ba2fd32 → 0.0.0-insiders.bbafc8e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/CHANGELOG.md +292 -3
  2. package/LICENSE +1 -2
  3. package/README.md +8 -4
  4. package/colors.js +2 -1
  5. package/defaultConfig.js +2 -1
  6. package/defaultTheme.js +2 -1
  7. package/lib/cli.js +96 -61
  8. package/lib/constants.js +1 -1
  9. package/lib/corePluginList.js +4 -0
  10. package/lib/corePlugins.js +399 -374
  11. package/lib/css/preflight.css +6 -5
  12. package/lib/featureFlags.js +7 -8
  13. package/lib/index.js +12 -3
  14. package/lib/lib/cacheInvalidation.js +69 -0
  15. package/lib/lib/collapseAdjacentRules.js +14 -1
  16. package/lib/lib/collapseDuplicateDeclarations.js +54 -3
  17. package/lib/lib/defaultExtractor.js +44 -0
  18. package/lib/lib/detectNesting.js +17 -2
  19. package/lib/lib/evaluateTailwindFunctions.js +10 -6
  20. package/lib/lib/expandApplyAtRules.js +264 -59
  21. package/lib/lib/expandTailwindAtRules.js +63 -46
  22. package/lib/lib/generateRules.js +181 -43
  23. package/lib/lib/normalizeTailwindDirectives.js +10 -2
  24. package/lib/lib/partitionApplyAtRules.js +53 -0
  25. package/lib/lib/resolveDefaultsAtRules.js +32 -14
  26. package/lib/lib/setupContextUtils.js +152 -153
  27. package/lib/lib/setupTrackingContext.js +8 -7
  28. package/lib/lib/sharedState.js +38 -5
  29. package/lib/lib/substituteScreenAtRules.js +7 -4
  30. package/{nesting → lib/postcss-plugins/nesting}/README.md +0 -0
  31. package/lib/postcss-plugins/nesting/index.js +17 -0
  32. package/lib/postcss-plugins/nesting/plugin.js +85 -0
  33. package/lib/processTailwindFeatures.js +10 -2
  34. package/lib/util/buildMediaQuery.js +13 -24
  35. package/lib/util/cloneNodes.js +12 -1
  36. package/lib/util/color.js +23 -8
  37. package/lib/util/createPlugin.js +1 -2
  38. package/lib/util/createUtilityPlugin.js +6 -10
  39. package/lib/util/dataTypes.js +25 -3
  40. package/lib/util/defaults.js +6 -0
  41. package/lib/util/flattenColorPalette.js +1 -3
  42. package/lib/util/formatVariantSelector.js +93 -9
  43. package/lib/util/isValidArbitraryValue.js +64 -0
  44. package/lib/util/log.js +10 -6
  45. package/lib/util/nameClass.js +1 -0
  46. package/lib/util/normalizeConfig.js +54 -22
  47. package/lib/util/normalizeScreens.js +59 -0
  48. package/lib/util/parseBoxShadowValue.js +117 -0
  49. package/lib/util/pluginUtils.js +18 -24
  50. package/lib/util/prefixSelector.js +4 -5
  51. package/lib/util/resolveConfig.js +52 -31
  52. package/lib/util/resolveConfigPath.js +1 -2
  53. package/lib/util/toColorValue.js +1 -2
  54. package/lib/util/toPath.js +6 -1
  55. package/lib/util/transformThemeValue.js +4 -8
  56. package/nesting/index.js +2 -12
  57. package/package.json +28 -33
  58. package/peers/index.js +6970 -7268
  59. package/plugin.js +2 -1
  60. package/resolveConfig.js +2 -1
  61. package/src/cli.js +62 -15
  62. package/src/corePluginList.js +1 -1
  63. package/src/corePlugins.js +329 -255
  64. package/src/css/preflight.css +6 -5
  65. package/src/featureFlags.js +3 -3
  66. package/src/index.js +14 -6
  67. package/src/lib/cacheInvalidation.js +52 -0
  68. package/src/lib/collapseAdjacentRules.js +16 -1
  69. package/src/lib/collapseDuplicateDeclarations.js +66 -1
  70. package/src/lib/defaultExtractor.js +50 -0
  71. package/src/lib/detectNesting.js +22 -3
  72. package/src/lib/evaluateTailwindFunctions.js +6 -3
  73. package/src/lib/expandApplyAtRules.js +285 -56
  74. package/src/lib/expandTailwindAtRules.js +75 -35
  75. package/src/lib/generateRules.js +154 -26
  76. package/src/lib/normalizeTailwindDirectives.js +7 -1
  77. package/src/lib/partitionApplyAtRules.js +52 -0
  78. package/src/lib/resolveDefaultsAtRules.js +35 -10
  79. package/src/lib/setupContextUtils.js +133 -103
  80. package/src/lib/setupTrackingContext.js +8 -7
  81. package/src/lib/sharedState.js +42 -4
  82. package/src/lib/substituteScreenAtRules.js +6 -3
  83. package/src/postcss-plugins/nesting/README.md +42 -0
  84. package/src/postcss-plugins/nesting/index.js +13 -0
  85. package/src/postcss-plugins/nesting/plugin.js +80 -0
  86. package/src/processTailwindFeatures.js +12 -2
  87. package/src/util/buildMediaQuery.js +14 -18
  88. package/src/util/cloneNodes.js +14 -1
  89. package/src/util/color.js +20 -7
  90. package/src/util/dataTypes.js +24 -6
  91. package/src/util/defaults.js +6 -0
  92. package/src/util/formatVariantSelector.js +92 -1
  93. package/src/util/isValidArbitraryValue.js +61 -0
  94. package/src/util/log.js +10 -6
  95. package/src/util/nameClass.js +1 -1
  96. package/src/util/normalizeConfig.js +24 -3
  97. package/src/util/normalizeScreens.js +45 -0
  98. package/src/util/parseBoxShadowValue.js +119 -0
  99. package/src/util/pluginUtils.js +3 -1
  100. package/src/util/prefixSelector.js +7 -5
  101. package/src/util/resolveConfig.js +41 -1
  102. package/src/util/toPath.js +23 -1
  103. package/stubs/defaultConfig.stub.js +27 -11
  104. package/lib/lib/setupWatchingContext.js +0 -288
  105. package/nesting/plugin.js +0 -41
  106. package/src/lib/setupWatchingContext.js +0 -311
@@ -10,12 +10,37 @@ var _isPlainObject = _interopRequireDefault(require("../util/isPlainObject"));
10
10
  var _prefixSelector = _interopRequireDefault(require("../util/prefixSelector"));
11
11
  var _pluginUtils = require("../util/pluginUtils");
12
12
  var _log = _interopRequireDefault(require("../util/log"));
13
+ var sharedState = _interopRequireWildcard(require("./sharedState"));
13
14
  var _formatVariantSelector = require("../util/formatVariantSelector");
15
+ var _nameClass = require("../util/nameClass");
16
+ var _dataTypes = require("../util/dataTypes");
17
+ var _isValidArbitraryValue = _interopRequireDefault(require("../util/isValidArbitraryValue"));
14
18
  function _interopRequireDefault(obj) {
15
19
  return obj && obj.__esModule ? obj : {
16
20
  default: obj
17
21
  };
18
22
  }
23
+ function _interopRequireWildcard(obj) {
24
+ if (obj && obj.__esModule) {
25
+ return obj;
26
+ } else {
27
+ var newObj = {};
28
+ if (obj != null) {
29
+ for(var key in obj){
30
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
31
+ var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {};
32
+ if (desc.get || desc.set) {
33
+ Object.defineProperty(newObj, key, desc);
34
+ } else {
35
+ newObj[key] = obj[key];
36
+ }
37
+ }
38
+ }
39
+ }
40
+ newObj.default = obj;
41
+ return newObj;
42
+ }
43
+ }
19
44
  let classNameParser = (0, _postcssSelectorParser).default((selectors)=>{
20
45
  return selectors.first.filter(({ type })=>type === 'class'
21
46
  ).pop().value;
@@ -30,32 +55,32 @@ function getClassNameFromSelector(selector) {
30
55
  // Example with dynamic classes:
31
56
  // ['grid-cols', '[[linename],1fr,auto]']
32
57
  // ['grid', 'cols-[[linename],1fr,auto]']
33
- function* candidatePermutations(candidate, lastIndex = Infinity) {
34
- if (lastIndex < 0) {
35
- return;
36
- }
37
- let dashIdx;
38
- if (lastIndex === Infinity && candidate.endsWith(']')) {
39
- let bracketIdx = candidate.indexOf('[');
40
- // If character before `[` isn't a dash or a slash, this isn't a dynamic class
41
- // eg. string[]
42
- dashIdx = [
43
- '-',
44
- '/'
45
- ].includes(candidate[bracketIdx - 1]) ? bracketIdx - 1 : -1;
46
- } else {
47
- dashIdx = candidate.lastIndexOf('-', lastIndex);
48
- }
49
- if (dashIdx < 0) {
50
- return;
58
+ function* candidatePermutations(candidate) {
59
+ let lastIndex = Infinity;
60
+ while(lastIndex >= 0){
61
+ let dashIdx;
62
+ if (lastIndex === Infinity && candidate.endsWith(']')) {
63
+ let bracketIdx = candidate.indexOf('[');
64
+ // If character before `[` isn't a dash or a slash, this isn't a dynamic class
65
+ // eg. string[]
66
+ dashIdx = [
67
+ '-',
68
+ '/'
69
+ ].includes(candidate[bracketIdx - 1]) ? bracketIdx - 1 : -1;
70
+ } else {
71
+ dashIdx = candidate.lastIndexOf('-', lastIndex);
72
+ }
73
+ if (dashIdx < 0) {
74
+ break;
75
+ }
76
+ let prefix = candidate.slice(0, dashIdx);
77
+ let modifier = candidate.slice(dashIdx + 1);
78
+ yield [
79
+ prefix,
80
+ modifier
81
+ ];
82
+ lastIndex = dashIdx - 1;
51
83
  }
52
- let prefix = candidate.slice(0, dashIdx);
53
- let modifier = candidate.slice(dashIdx + 1);
54
- yield [
55
- prefix,
56
- modifier
57
- ];
58
- yield* candidatePermutations(candidate, dashIdx - 1);
59
84
  }
60
85
  function applyPrefix(matches, context) {
61
86
  if (matches.length === 0 || context.tailwindConfig.prefix === '') {
@@ -69,15 +94,21 @@ function applyPrefix(matches, context) {
69
94
  match[1].clone()
70
95
  ]
71
96
  });
97
+ let classCandidate = match[1].raws.tailwind.classCandidate;
72
98
  container.walkRules((r)=>{
73
- r.selector = (0, _prefixSelector).default(context.tailwindConfig.prefix, r.selector);
99
+ // If this is a negative utility with a dash *before* the prefix we
100
+ // have to ensure that the generated selector matches the candidate
101
+ // Not doing this will cause `-tw-top-1` to generate the class `.tw--top-1`
102
+ // The disconnect between candidate <-> class can cause @apply to hard crash.
103
+ let shouldPrependNegative = classCandidate.startsWith('-');
104
+ r.selector = (0, _prefixSelector).default(context.tailwindConfig.prefix, r.selector, shouldPrependNegative);
74
105
  });
75
106
  match[1] = container.nodes[0];
76
107
  }
77
108
  }
78
109
  return matches;
79
110
  }
80
- function applyImportant(matches) {
111
+ function applyImportant(matches, classCandidate) {
81
112
  if (matches.length === 0) {
82
113
  return matches;
83
114
  }
@@ -90,7 +121,10 @@ function applyImportant(matches) {
90
121
  });
91
122
  container.walkRules((r)=>{
92
123
  r.selector = (0, _pluginUtils).updateAllClasses(r.selector, (className)=>{
93
- return `!${className}`;
124
+ if (className === classCandidate) {
125
+ return `!${className}`;
126
+ }
127
+ return className;
94
128
  });
95
129
  r.walkDecls((d)=>d.important = true
96
130
  );
@@ -120,10 +154,14 @@ function applyVariant(variant, matches, context) {
120
154
  if (context.variantMap.has(variant)) {
121
155
  let variantFunctionTuples = context.variantMap.get(variant);
122
156
  let result = [];
123
- for (let [meta, rule] of matches){
157
+ for (let [meta, rule1] of matches){
158
+ // Don't generate variants for user css
159
+ if (meta.layer === 'user') {
160
+ continue;
161
+ }
124
162
  let container = _postcss.default.root({
125
163
  nodes: [
126
- rule.clone()
164
+ rule1.clone()
127
165
  ]
128
166
  });
129
167
  for (let [variantSort, variantFunction] of variantFunctionTuples){
@@ -210,6 +248,14 @@ function applyVariant(variant, matches, context) {
210
248
  rule.selector = before;
211
249
  });
212
250
  }
251
+ // This tracks the originating layer for the variant
252
+ // For example:
253
+ // .sm:underline {} is a variant of something in the utilities layer
254
+ // .sm:container {} is a variant of the container component
255
+ clone.nodes[0].raws.tailwind = {
256
+ ...clone.nodes[0].raws.tailwind,
257
+ parentLayer: meta.layer
258
+ };
213
259
  var _collectedFormats;
214
260
  let withOffset = [
215
261
  {
@@ -226,8 +272,7 @@ function applyVariant(variant, matches, context) {
226
272
  }
227
273
  return [];
228
274
  }
229
- function parseRules(rule, cache, options = {
230
- }) {
275
+ function parseRules(rule, cache, options = {}) {
231
276
  // PostCSS node
232
277
  if (!(0, _isPlainObject).default(rule) && !Array.isArray(rule)) {
233
278
  return [
@@ -250,6 +295,72 @@ function parseRules(rule, cache, options = {
250
295
  options
251
296
  ];
252
297
  }
298
+ const IS_VALID_PROPERTY_NAME = /^[a-z_-]/;
299
+ function isValidPropName(name) {
300
+ return IS_VALID_PROPERTY_NAME.test(name);
301
+ }
302
+ /**
303
+ * @param {string} declaration
304
+ * @returns {boolean}
305
+ */ function looksLikeUri(declaration) {
306
+ // Quick bailout for obvious non-urls
307
+ // This doesn't support schemes that don't use a leading // but that's unlikely to be a problem
308
+ if (!declaration.includes('://')) {
309
+ return false;
310
+ }
311
+ try {
312
+ const url = new URL(declaration);
313
+ return url.scheme !== '' && url.host !== '';
314
+ } catch (err) {
315
+ // Definitely not a valid url
316
+ return false;
317
+ }
318
+ }
319
+ function isParsableCssValue(property, value) {
320
+ // We don't want to to treat [https://example.com] as a custom property
321
+ // Even though, according to the CSS grammar, it's a totally valid CSS declaration
322
+ // So we short-circuit here by checking if the custom property looks like a url
323
+ if (looksLikeUri(`${property}:${value}`)) {
324
+ return false;
325
+ }
326
+ try {
327
+ _postcss.default.parse(`a{${property}:${value}}`).toResult();
328
+ return true;
329
+ } catch (err) {
330
+ return false;
331
+ }
332
+ }
333
+ function extractArbitraryProperty(classCandidate, context) {
334
+ var ref;
335
+ let [, property, value] = (ref = classCandidate.match(/^\[([a-zA-Z0-9-_]+):(\S+)\]$/)) !== null && ref !== void 0 ? ref : [];
336
+ if (value === undefined) {
337
+ return null;
338
+ }
339
+ if (!isValidPropName(property)) {
340
+ return null;
341
+ }
342
+ if (!(0, _isValidArbitraryValue).default(value)) {
343
+ return null;
344
+ }
345
+ let normalized = (0, _dataTypes).normalize(value);
346
+ if (!isParsableCssValue(property, normalized)) {
347
+ return null;
348
+ }
349
+ return [
350
+ [
351
+ {
352
+ sort: context.arbitraryPropertiesSort,
353
+ layer: 'utilities'
354
+ },
355
+ ()=>({
356
+ [(0, _nameClass).asClass(classCandidate)]: {
357
+ [property]: normalized
358
+ }
359
+ })
360
+ ,
361
+ ],
362
+ ];
363
+ }
253
364
  function* resolveMatchedPlugins(classCandidate, context) {
254
365
  if (context.candidateRuleMap.has(classCandidate)) {
255
366
  yield [
@@ -257,6 +368,14 @@ function* resolveMatchedPlugins(classCandidate, context) {
257
368
  'DEFAULT'
258
369
  ];
259
370
  }
371
+ yield* (function*(arbitraryPropertyRule) {
372
+ if (arbitraryPropertyRule !== null) {
373
+ yield [
374
+ arbitraryPropertyRule,
375
+ 'DEFAULT'
376
+ ];
377
+ }
378
+ })(extractArbitraryProperty(classCandidate, context));
260
379
  let candidatePrefix = classCandidate;
261
380
  let negative = false;
262
381
  const twConfigPrefix = context.tailwindConfig.prefix;
@@ -277,13 +396,26 @@ function* resolveMatchedPlugins(classCandidate, context) {
277
396
  context.candidateRuleMap.get(prefix),
278
397
  negative ? `-${modifier}` : modifier
279
398
  ];
280
- return;
281
399
  }
282
400
  }
283
401
  }
284
402
  function splitWithSeparator(input, separator) {
403
+ if (input === sharedState.NOT_ON_DEMAND) {
404
+ return [
405
+ sharedState.NOT_ON_DEMAND
406
+ ];
407
+ }
285
408
  return input.split(new RegExp(`\\${separator}(?![^[]*\\])`, 'g'));
286
409
  }
410
+ function* recordCandidates(matches, classCandidate) {
411
+ for (const match of matches){
412
+ match[1].raws.tailwind = {
413
+ ...match[1].raws.tailwind,
414
+ classCandidate
415
+ };
416
+ yield match;
417
+ }
418
+ }
287
419
  function* resolveMatches(candidate, context) {
288
420
  let separator = context.tailwindConfig.separator;
289
421
  let [classCandidate, ...variants] = splitWithSeparator(candidate, separator).reverse();
@@ -353,9 +485,9 @@ function* resolveMatches(candidate, context) {
353
485
  // Only keep the result of the very first plugin if we are dealing with
354
486
  // arbitrary values, to protect against ambiguity.
355
487
  if (isArbitraryValue(modifier) && matches.length > 1) {
356
- var ref;
488
+ var ref1;
357
489
  let typesPerPlugin = matches.map((match)=>new Set([
358
- ...(ref = typesByMatches.get(match)) !== null && ref !== void 0 ? ref : []
490
+ ...(ref1 = typesByMatches.get(match)) !== null && ref1 !== void 0 ? ref1 : []
359
491
  ])
360
492
  );
361
493
  // Remove duplicates, so that we can detect proper unique types for each plugin.
@@ -393,20 +525,26 @@ function* resolveMatches(candidate, context) {
393
525
  ]);
394
526
  continue;
395
527
  }
396
- matches = applyPrefix(matches.flat(), context);
528
+ matches = matches.flat();
529
+ matches = Array.from(recordCandidates(matches, classCandidate));
530
+ matches = applyPrefix(matches, context);
397
531
  if (important) {
398
- matches = applyImportant(matches, context);
532
+ matches = applyImportant(matches, classCandidate);
399
533
  }
400
534
  for (let variant of variants){
401
535
  matches = applyVariant(variant, matches, context);
402
536
  }
403
- for (let match of matches){
537
+ for (let match1 of matches){
538
+ match1[1].raws.tailwind = {
539
+ ...match1[1].raws.tailwind,
540
+ candidate
541
+ };
404
542
  // Apply final format selector
405
- if (match[0].collectedFormats) {
406
- let finalFormat = (0, _formatVariantSelector).formatVariantSelector('&', ...match[0].collectedFormats);
543
+ if (match1[0].collectedFormats) {
544
+ let finalFormat = (0, _formatVariantSelector).formatVariantSelector('&', ...match1[0].collectedFormats);
407
545
  let container = _postcss.default.root({
408
546
  nodes: [
409
- match[1].clone()
547
+ match1[1].clone()
410
548
  ]
411
549
  });
412
550
  container.walkRules((rule)=>{
@@ -417,9 +555,9 @@ function* resolveMatches(candidate, context) {
417
555
  context
418
556
  });
419
557
  });
420
- match[1] = container.nodes[0];
558
+ match1[1] = container.nodes[0];
421
559
  }
422
- yield match;
560
+ yield match1;
423
561
  }
424
562
  }
425
563
  }
@@ -12,7 +12,11 @@ function _interopRequireDefault(obj) {
12
12
  function normalizeTailwindDirectives(root) {
13
13
  let tailwindDirectives = new Set();
14
14
  let layerDirectives = new Set();
15
+ let applyDirectives = new Set();
15
16
  root.walkAtRules((atRule)=>{
17
+ if (atRule.name === 'apply') {
18
+ applyDirectives.add(atRule);
19
+ }
16
20
  if (atRule.name === 'import') {
17
21
  if (atRule.params === '"tailwindcss/base"' || atRule.params === "'tailwindcss/base'") {
18
22
  atRule.name = 'tailwind';
@@ -45,7 +49,8 @@ function normalizeTailwindDirectives(root) {
45
49
  ].includes(atRule.name)) {
46
50
  _log.default.warn(`${atRule.name}-at-rule-deprecated`, [
47
51
  `The \`@${atRule.name}\` directive has been deprecated in Tailwind CSS v3.0.`,
48
- `Use \`@layer utilities\` or \`@layer components\` instead.`,
52
+ `Use \`@layer utilities\` or \`@layer components\` instead.`,
53
+ 'https://tailwindcss.com/docs/upgrade-guide#replace-variants-with-layer',
49
54
  ]);
50
55
  }
51
56
  layerDirectives.add(atRule);
@@ -72,5 +77,8 @@ function normalizeTailwindDirectives(root) {
72
77
  }
73
78
  }
74
79
  }
75
- return tailwindDirectives;
80
+ return {
81
+ tailwindDirectives,
82
+ applyDirectives
83
+ };
76
84
  }
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ exports.default = expandApplyAtRules;
6
+ function partitionRules(root) {
7
+ if (!root.walkAtRules) return;
8
+ let applyParents = new Set();
9
+ root.walkAtRules('apply', (rule)=>{
10
+ applyParents.add(rule.parent);
11
+ });
12
+ if (applyParents.size === 0) {
13
+ return;
14
+ }
15
+ for (let rule1 of applyParents){
16
+ let nodeGroups = [];
17
+ let lastGroup = [];
18
+ for (let node of rule1.nodes){
19
+ if (node.type === 'atrule' && node.name === 'apply') {
20
+ if (lastGroup.length > 0) {
21
+ nodeGroups.push(lastGroup);
22
+ lastGroup = [];
23
+ }
24
+ nodeGroups.push([
25
+ node
26
+ ]);
27
+ } else {
28
+ lastGroup.push(node);
29
+ }
30
+ }
31
+ if (lastGroup.length > 0) {
32
+ nodeGroups.push(lastGroup);
33
+ }
34
+ if (nodeGroups.length === 1) {
35
+ continue;
36
+ }
37
+ for (let group of [
38
+ ...nodeGroups
39
+ ].reverse()){
40
+ let clone = rule1.clone({
41
+ nodes: []
42
+ });
43
+ clone.append(group);
44
+ rule1.after(clone);
45
+ }
46
+ rule1.remove();
47
+ }
48
+ }
49
+ function expandApplyAtRules() {
50
+ return (root)=>{
51
+ partitionRules(root);
52
+ };
53
+ }
@@ -47,8 +47,8 @@ function minimumImpactSelector(nodes) {
47
47
  let splitPointIdx = rest.findIndex((n)=>searchFor.has(n.type)
48
48
  );
49
49
  if (splitPointIdx === -1) return rest.reverse().join('').trim();
50
- let node = rest[splitPointIdx];
51
- let bestNode = getNode[node.type] ? getNode[node.type](node) : node;
50
+ let node1 = rest[splitPointIdx];
51
+ let bestNode = getNode[node1.type] ? getNode[node1.type](node1) : node1;
52
52
  rest = rest.slice(0, splitPointIdx);
53
53
  let combinatorIdx = rest.findIndex((n)=>n.type === 'combinator' && n.value === '>'
54
54
  );
@@ -79,7 +79,7 @@ function extractElementSelector(selector) {
79
79
  function resolveDefaultsAtRules({ tailwindConfig }) {
80
80
  return (root)=>{
81
81
  let variableNodeMap = new Map();
82
- let universals = new Set();
82
+ /** @type {Set<import('postcss').AtRule>} */ let universals = new Set();
83
83
  root.walkAtRules('defaults', (rule)=>{
84
84
  if (rule.nodes && rule.nodes.length > 0) {
85
85
  universals.add(rule);
@@ -93,32 +93,50 @@ function resolveDefaultsAtRules({ tailwindConfig }) {
93
93
  rule.remove();
94
94
  });
95
95
  for (let universal of universals){
96
- let selectors = new Set();
96
+ /** @type {Map<string, Set<string>>} */ let selectorGroups = new Map();
97
97
  var ref;
98
98
  let rules = (ref = variableNodeMap.get(universal.params)) !== null && ref !== void 0 ? ref : [];
99
99
  for (let rule of rules){
100
100
  for (let selector of extractElementSelector(rule.selector)){
101
+ // If selector contains a vendor prefix after a pseudo element or class,
102
+ // we consider them separately because merging the declarations into
103
+ // a single rule will cause browsers that do not understand the
104
+ // vendor prefix to throw out the whole rule
105
+ let selectorGroupName = selector.includes(':-') || selector.includes('::-') ? selector : '__DEFAULT__';
106
+ var ref1;
107
+ let selectors = (ref1 = selectorGroups.get(selectorGroupName)) !== null && ref1 !== void 0 ? ref1 : new Set();
108
+ selectorGroups.set(selectorGroupName, selectors);
101
109
  selectors.add(selector);
102
110
  }
103
111
  }
104
- if (selectors.size === 0) {
105
- universal.remove();
106
- continue;
107
- }
108
- let universalRule = _postcss.default.rule();
109
112
  if ((0, _featureFlags).flagEnabled(tailwindConfig, 'optimizeUniversalDefaults')) {
110
- universalRule.selectors = [
111
- ...selectors
112
- ];
113
+ if (selectorGroups.size === 0) {
114
+ universal.remove();
115
+ continue;
116
+ }
117
+ for (let [, selectors] of selectorGroups){
118
+ let universalRule = _postcss.default.rule({
119
+ source: universal.source
120
+ });
121
+ universalRule.selectors = [
122
+ ...selectors
123
+ ];
124
+ universalRule.append(universal.nodes.map((node)=>node.clone()
125
+ ));
126
+ universal.before(universalRule);
127
+ }
113
128
  } else {
129
+ let universalRule = _postcss.default.rule({
130
+ source: universal.source
131
+ });
114
132
  universalRule.selectors = [
115
133
  '*',
116
134
  '::before',
117
135
  '::after'
118
136
  ];
137
+ universalRule.append(universal.nodes);
138
+ universal.before(universalRule);
119
139
  }
120
- universalRule.append(universal.nodes);
121
- universal.before(universalRule);
122
140
  universal.remove();
123
141
  }
124
142
  };