autoprefixer 9.3.1 → 9.4.3
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.
- package/CHANGELOG.md +15 -0
- package/README.md +501 -89
- package/lib/at-rule.js +2 -2
- package/lib/browsers.js +6 -6
- package/lib/declaration.js +26 -26
- package/lib/hacks/align-content.js +4 -4
- package/lib/hacks/align-items.js +4 -4
- package/lib/hacks/align-self.js +14 -8
- package/lib/hacks/block-logical.js +2 -2
- package/lib/hacks/border-radius.js +2 -2
- package/lib/hacks/break-props.js +6 -6
- package/lib/hacks/color-adjust.js +2 -2
- package/lib/hacks/display-flex.js +6 -6
- package/lib/hacks/flex-basis.js +4 -4
- package/lib/hacks/flex-direction.js +4 -4
- package/lib/hacks/flex-grow.js +2 -2
- package/lib/hacks/flex-shrink.js +4 -4
- package/lib/hacks/flex.js +4 -4
- package/lib/hacks/gradient.js +32 -32
- package/lib/hacks/grid-column-align.js +4 -4
- package/lib/hacks/grid-row-align.js +4 -4
- package/lib/hacks/grid-rows-columns.js +93 -11
- package/lib/hacks/grid-start.js +4 -4
- package/lib/hacks/grid-template-areas.js +14 -62
- package/lib/hacks/grid-utils.js +129 -3
- package/lib/hacks/image-rendering.js +8 -8
- package/lib/hacks/inline-logical.js +2 -2
- package/lib/hacks/justify-content.js +4 -4
- package/lib/hacks/mask-border.js +2 -2
- package/lib/hacks/order.js +4 -4
- package/lib/hacks/overscroll-behavior.js +4 -4
- package/lib/hacks/pixelated.js +2 -2
- package/lib/hacks/placeholder.js +2 -2
- package/lib/hacks/transform-decl.js +6 -6
- package/lib/old-selector.js +2 -2
- package/lib/prefixer.js +8 -8
- package/lib/prefixes.js +18 -18
- package/lib/processor.js +88 -21
- package/lib/resolution.js +6 -6
- package/lib/selector.js +16 -16
- package/lib/supports.js +30 -30
- package/lib/transition.js +22 -22
- package/lib/value.js +12 -12
- package/package.json +4 -4
package/lib/hacks/gradient.js
CHANGED
|
@@ -101,11 +101,11 @@ function (_Value) {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
return ast.toString();
|
|
104
|
-
}
|
|
104
|
+
}
|
|
105
105
|
/**
|
|
106
106
|
* Replace first token
|
|
107
107
|
*/
|
|
108
|
-
|
|
108
|
+
;
|
|
109
109
|
|
|
110
110
|
_proto.replaceFirst = function replaceFirst(params) {
|
|
111
111
|
for (var _len2 = arguments.length, words = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
@@ -126,21 +126,21 @@ function (_Value) {
|
|
|
126
126
|
};
|
|
127
127
|
});
|
|
128
128
|
return prefix.concat(params.slice(1));
|
|
129
|
-
}
|
|
129
|
+
}
|
|
130
130
|
/**
|
|
131
131
|
* Convert angle unit to deg
|
|
132
132
|
*/
|
|
133
|
-
|
|
133
|
+
;
|
|
134
134
|
|
|
135
135
|
_proto.normalizeUnit = function normalizeUnit(str, full) {
|
|
136
136
|
var num = parseFloat(str);
|
|
137
137
|
var deg = num / full * 360;
|
|
138
138
|
return deg + "deg";
|
|
139
|
-
}
|
|
139
|
+
}
|
|
140
140
|
/**
|
|
141
141
|
* Normalize angle
|
|
142
142
|
*/
|
|
143
|
-
|
|
143
|
+
;
|
|
144
144
|
|
|
145
145
|
_proto.normalize = function normalize(nodes) {
|
|
146
146
|
if (!nodes[0]) return nodes;
|
|
@@ -168,11 +168,11 @@ function (_Value) {
|
|
|
168
168
|
}
|
|
169
169
|
|
|
170
170
|
return nodes;
|
|
171
|
-
}
|
|
171
|
+
}
|
|
172
172
|
/**
|
|
173
173
|
* Replace old direction to new
|
|
174
174
|
*/
|
|
175
|
-
|
|
175
|
+
;
|
|
176
176
|
|
|
177
177
|
_proto.newDirection = function newDirection(params) {
|
|
178
178
|
if (params[0].value === 'to') {
|
|
@@ -204,11 +204,11 @@ function (_Value) {
|
|
|
204
204
|
}
|
|
205
205
|
|
|
206
206
|
return params;
|
|
207
|
-
}
|
|
207
|
+
}
|
|
208
208
|
/**
|
|
209
209
|
* Look for at word
|
|
210
210
|
*/
|
|
211
|
-
|
|
211
|
+
;
|
|
212
212
|
|
|
213
213
|
_proto.isRadial = function isRadial(params) {
|
|
214
214
|
var state = 'before';
|
|
@@ -241,11 +241,11 @@ function (_Value) {
|
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
return false;
|
|
244
|
-
}
|
|
244
|
+
}
|
|
245
245
|
/**
|
|
246
246
|
* Change new direction to old
|
|
247
247
|
*/
|
|
248
|
-
|
|
248
|
+
;
|
|
249
249
|
|
|
250
250
|
_proto.convertDirection = function convertDirection(params) {
|
|
251
251
|
if (params.length > 0) {
|
|
@@ -259,11 +259,11 @@ function (_Value) {
|
|
|
259
259
|
}
|
|
260
260
|
|
|
261
261
|
return params;
|
|
262
|
-
}
|
|
262
|
+
}
|
|
263
263
|
/**
|
|
264
264
|
* Replace `to top left` to `bottom right`
|
|
265
265
|
*/
|
|
266
|
-
|
|
266
|
+
;
|
|
267
267
|
|
|
268
268
|
_proto.fixDirection = function fixDirection(params) {
|
|
269
269
|
params.splice(0, 2);
|
|
@@ -290,11 +290,11 @@ function (_Value) {
|
|
|
290
290
|
param.value = this.revertDirection(param.value);
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
|
-
}
|
|
293
|
+
}
|
|
294
294
|
/**
|
|
295
295
|
* Add 90 degrees
|
|
296
296
|
*/
|
|
297
|
-
|
|
297
|
+
;
|
|
298
298
|
|
|
299
299
|
_proto.fixAngle = function fixAngle(params) {
|
|
300
300
|
var first = params[0].value;
|
|
@@ -302,11 +302,11 @@ function (_Value) {
|
|
|
302
302
|
first = Math.abs(450 - first) % 360;
|
|
303
303
|
first = this.roundFloat(first, 3);
|
|
304
304
|
params[0].value = first + "deg";
|
|
305
|
-
}
|
|
305
|
+
}
|
|
306
306
|
/**
|
|
307
307
|
* Fix radial direction syntax
|
|
308
308
|
*/
|
|
309
|
-
|
|
309
|
+
;
|
|
310
310
|
|
|
311
311
|
_proto.fixRadial = function fixRadial(params) {
|
|
312
312
|
var first = [];
|
|
@@ -342,19 +342,19 @@ function (_Value) {
|
|
|
342
342
|
|
|
343
343
|
_proto.revertDirection = function revertDirection(word) {
|
|
344
344
|
return this.directions[word.toLowerCase()] || word;
|
|
345
|
-
}
|
|
345
|
+
}
|
|
346
346
|
/**
|
|
347
347
|
* Round float and save digits under dot
|
|
348
348
|
*/
|
|
349
|
-
|
|
349
|
+
;
|
|
350
350
|
|
|
351
351
|
_proto.roundFloat = function roundFloat(float, digits) {
|
|
352
352
|
return parseFloat(float.toFixed(digits));
|
|
353
|
-
}
|
|
353
|
+
}
|
|
354
354
|
/**
|
|
355
355
|
* Convert to old webkit syntax
|
|
356
356
|
*/
|
|
357
|
-
|
|
357
|
+
;
|
|
358
358
|
|
|
359
359
|
_proto.oldWebkit = function oldWebkit(node) {
|
|
360
360
|
var nodes = node.nodes;
|
|
@@ -409,11 +409,11 @@ function (_Value) {
|
|
|
409
409
|
}, this.cloneDiv(node.nodes));
|
|
410
410
|
node.value = '-webkit-gradient';
|
|
411
411
|
return true;
|
|
412
|
-
}
|
|
412
|
+
}
|
|
413
413
|
/**
|
|
414
414
|
* Change direction syntax to old webkit
|
|
415
415
|
*/
|
|
416
|
-
|
|
416
|
+
;
|
|
417
417
|
|
|
418
418
|
_proto.oldDirection = function oldDirection(params) {
|
|
419
419
|
var div = this.cloneDiv(params[0]);
|
|
@@ -453,11 +453,11 @@ function (_Value) {
|
|
|
453
453
|
}, div];
|
|
454
454
|
return params[0];
|
|
455
455
|
}
|
|
456
|
-
}
|
|
456
|
+
}
|
|
457
457
|
/**
|
|
458
458
|
* Get div token from exists parameters
|
|
459
459
|
*/
|
|
460
|
-
|
|
460
|
+
;
|
|
461
461
|
|
|
462
462
|
_proto.cloneDiv = function cloneDiv(params) {
|
|
463
463
|
for (var _iterator6 = params, _isArray6 = Array.isArray(_iterator6), _i7 = 0, _iterator6 = _isArray6 ? _iterator6 : _iterator6[Symbol.iterator]();;) {
|
|
@@ -484,11 +484,11 @@ function (_Value) {
|
|
|
484
484
|
value: ',',
|
|
485
485
|
after: ' '
|
|
486
486
|
};
|
|
487
|
-
}
|
|
487
|
+
}
|
|
488
488
|
/**
|
|
489
489
|
* Change colors syntax to old webkit
|
|
490
490
|
*/
|
|
491
|
-
|
|
491
|
+
;
|
|
492
492
|
|
|
493
493
|
_proto.colorStops = function colorStops(params) {
|
|
494
494
|
var result = [];
|
|
@@ -536,11 +536,11 @@ function (_Value) {
|
|
|
536
536
|
}
|
|
537
537
|
|
|
538
538
|
return result;
|
|
539
|
-
}
|
|
539
|
+
}
|
|
540
540
|
/**
|
|
541
541
|
* Remove old WebKit gradient too
|
|
542
542
|
*/
|
|
543
|
-
|
|
543
|
+
;
|
|
544
544
|
|
|
545
545
|
_proto.old = function old(prefix) {
|
|
546
546
|
if (prefix === '-webkit-') {
|
|
@@ -551,11 +551,11 @@ function (_Value) {
|
|
|
551
551
|
} else {
|
|
552
552
|
return _Value.prototype.old.call(this, prefix);
|
|
553
553
|
}
|
|
554
|
-
}
|
|
554
|
+
}
|
|
555
555
|
/**
|
|
556
556
|
* Do not add non-webkit prefixes for list-style and object
|
|
557
557
|
*/
|
|
558
|
-
|
|
558
|
+
;
|
|
559
559
|
|
|
560
560
|
_proto.add = function add(decl, prefix) {
|
|
561
561
|
var p = decl.prop;
|
|
@@ -24,19 +24,19 @@ function (_Declaration) {
|
|
|
24
24
|
*/
|
|
25
25
|
_proto.check = function check(decl) {
|
|
26
26
|
return decl.value.indexOf('flex-') === -1 && decl.value !== 'baseline';
|
|
27
|
-
}
|
|
27
|
+
}
|
|
28
28
|
/**
|
|
29
29
|
* Change property name for IE
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
;
|
|
32
32
|
|
|
33
33
|
_proto.prefixed = function prefixed(prop, prefix) {
|
|
34
34
|
return prefix + 'grid-column-align';
|
|
35
|
-
}
|
|
35
|
+
}
|
|
36
36
|
/**
|
|
37
37
|
* Change IE property back
|
|
38
38
|
*/
|
|
39
|
-
|
|
39
|
+
;
|
|
40
40
|
|
|
41
41
|
_proto.normalize = function normalize() {
|
|
42
42
|
return 'justify-self';
|
|
@@ -24,19 +24,19 @@ function (_Declaration) {
|
|
|
24
24
|
*/
|
|
25
25
|
_proto.check = function check(decl) {
|
|
26
26
|
return decl.value.indexOf('flex-') === -1 && decl.value !== 'baseline';
|
|
27
|
-
}
|
|
27
|
+
}
|
|
28
28
|
/**
|
|
29
29
|
* Change property name for IE
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
;
|
|
32
32
|
|
|
33
33
|
_proto.prefixed = function prefixed(prop, prefix) {
|
|
34
34
|
return prefix + 'grid-row-align';
|
|
35
|
-
}
|
|
35
|
+
}
|
|
36
36
|
/**
|
|
37
37
|
* Change IE property back
|
|
38
38
|
*/
|
|
39
|
-
|
|
39
|
+
;
|
|
40
40
|
|
|
41
41
|
_proto.normalize = function normalize() {
|
|
42
42
|
return 'align-self';
|
|
@@ -10,7 +10,12 @@ var Declaration = require('../declaration');
|
|
|
10
10
|
|
|
11
11
|
var _require = require('./grid-utils'),
|
|
12
12
|
prefixTrackProp = _require.prefixTrackProp,
|
|
13
|
-
prefixTrackValue = _require.prefixTrackValue
|
|
13
|
+
prefixTrackValue = _require.prefixTrackValue,
|
|
14
|
+
autoplaceGridItems = _require.autoplaceGridItems,
|
|
15
|
+
getGridGap = _require.getGridGap,
|
|
16
|
+
inheritGridGap = _require.inheritGridGap;
|
|
17
|
+
|
|
18
|
+
var Processor = require('../processor');
|
|
14
19
|
|
|
15
20
|
var GridRowsColumns =
|
|
16
21
|
/*#__PURE__*/
|
|
@@ -35,28 +40,105 @@ function (_Declaration) {
|
|
|
35
40
|
}
|
|
36
41
|
|
|
37
42
|
return _Declaration.prototype.prefixed.call(this, prop, prefix);
|
|
38
|
-
}
|
|
43
|
+
}
|
|
39
44
|
/**
|
|
40
45
|
* Change IE property back
|
|
41
46
|
*/
|
|
42
|
-
|
|
47
|
+
;
|
|
43
48
|
|
|
44
49
|
_proto.normalize = function normalize(prop) {
|
|
45
50
|
return prop.replace(/^grid-(rows|columns)/, 'grid-template-$1');
|
|
46
51
|
};
|
|
47
|
-
/**
|
|
48
|
-
* Change repeating syntax for IE
|
|
49
|
-
*/
|
|
50
52
|
|
|
53
|
+
_proto.insert = function insert(decl, prefix, prefixes, result) {
|
|
54
|
+
if (prefix !== '-ms-') return _Declaration.prototype.insert.call(this, decl, prefix, prefixes);
|
|
55
|
+
var parent = decl.parent,
|
|
56
|
+
prop = decl.prop,
|
|
57
|
+
value = decl.value;
|
|
58
|
+
var isRowProp = prop.includes('rows');
|
|
59
|
+
var isColumnProp = prop.includes('columns');
|
|
60
|
+
var hasGridTemplate = parent.some(function (i) {
|
|
61
|
+
return i.prop === 'grid-template' || i.prop === 'grid-template-areas';
|
|
62
|
+
});
|
|
63
|
+
/**
|
|
64
|
+
* Not to prefix rows declaration if grid-template(-areas) is present
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
if (hasGridTemplate && isRowProp) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
var processor = new Processor({});
|
|
72
|
+
var status = processor.gridStatus(parent, result);
|
|
73
|
+
var gap = getGridGap(decl);
|
|
74
|
+
gap = inheritGridGap(decl, gap) || gap;
|
|
75
|
+
var gapValue = isRowProp ? gap.row : gap.column;
|
|
76
|
+
|
|
77
|
+
if ((status === 'no-autoplace' || status === true) && !hasGridTemplate) {
|
|
78
|
+
gapValue = null;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
var prefixValue = prefixTrackValue({
|
|
82
|
+
value: value,
|
|
83
|
+
gap: gapValue
|
|
84
|
+
});
|
|
85
|
+
/**
|
|
86
|
+
* Insert prefixes
|
|
87
|
+
*/
|
|
51
88
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
89
|
+
decl.cloneBefore({
|
|
90
|
+
prop: prefixTrackProp({
|
|
91
|
+
prop: prop,
|
|
92
|
+
prefix: prefix
|
|
93
|
+
}),
|
|
94
|
+
value: prefixValue
|
|
95
|
+
});
|
|
96
|
+
var autoflow = parent.nodes.find(function (i) {
|
|
97
|
+
return i.prop === 'grid-auto-flow';
|
|
98
|
+
});
|
|
99
|
+
var autoflowValue = 'row';
|
|
100
|
+
|
|
101
|
+
if (autoflow && !processor.disabled(autoflow, result)) {
|
|
102
|
+
autoflowValue = autoflow.value.trim();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (status === 'autoplace') {
|
|
106
|
+
/**
|
|
107
|
+
* Show warning if grid-template-rows decl is not found
|
|
108
|
+
*/
|
|
109
|
+
var rowDecl = parent.nodes.find(function (i) {
|
|
110
|
+
return i.prop === 'grid-template-rows';
|
|
56
111
|
});
|
|
112
|
+
|
|
113
|
+
if (!rowDecl && hasGridTemplate) {
|
|
114
|
+
return undefined;
|
|
115
|
+
} else if (!rowDecl && !hasGridTemplate) {
|
|
116
|
+
decl.warn(result, "Autoplacement does not work without grid-template-rows property");
|
|
117
|
+
return undefined;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Show warning if grid-template-columns decl is not found
|
|
121
|
+
*/
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
var columnDecl = parent.nodes.find(function (i) {
|
|
125
|
+
return i.prop === 'grid-template-columns';
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
if (!columnDecl && !hasGridTemplate) {
|
|
129
|
+
decl.warn(result, "Autoplacement does not work without grid-template-columns property");
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Autoplace grid items
|
|
133
|
+
*/
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
if (isColumnProp && !hasGridTemplate) {
|
|
137
|
+
autoplaceGridItems(decl, result, gap, autoflowValue);
|
|
138
|
+
}
|
|
57
139
|
}
|
|
58
140
|
|
|
59
|
-
return
|
|
141
|
+
return undefined;
|
|
60
142
|
};
|
|
61
143
|
|
|
62
144
|
return GridRowsColumns;
|
package/lib/hacks/grid-start.js
CHANGED
|
@@ -25,19 +25,19 @@ function (_Declaration) {
|
|
|
25
25
|
_proto.check = function check(decl) {
|
|
26
26
|
var value = decl.value;
|
|
27
27
|
return value.indexOf('/') === -1 || value.indexOf('span') !== -1;
|
|
28
|
-
}
|
|
28
|
+
}
|
|
29
29
|
/**
|
|
30
30
|
* Return a final spec property
|
|
31
31
|
*/
|
|
32
|
-
|
|
32
|
+
;
|
|
33
33
|
|
|
34
34
|
_proto.normalize = function normalize(prop) {
|
|
35
35
|
return prop.replace('-start', '');
|
|
36
|
-
}
|
|
36
|
+
}
|
|
37
37
|
/**
|
|
38
38
|
* Change property name for IE
|
|
39
39
|
*/
|
|
40
|
-
|
|
40
|
+
;
|
|
41
41
|
|
|
42
42
|
_proto.prefixed = function prefixed(prop, prefix) {
|
|
43
43
|
var result = _Declaration.prototype.prefixed.call(this, prop, prefix);
|
|
@@ -41,78 +41,30 @@ function (_Declaration) {
|
|
|
41
41
|
var hasRows = false;
|
|
42
42
|
var parent = decl.parent;
|
|
43
43
|
var gap = getGridGap(decl);
|
|
44
|
-
|
|
45
|
-
//
|
|
44
|
+
gap = inheritGridGap(decl, gap) || gap; // remove already prefixed rows
|
|
45
|
+
// to prevent doubling prefixes
|
|
46
46
|
|
|
47
|
-
parent.walkDecls(/-ms-grid-
|
|
47
|
+
parent.walkDecls(/-ms-grid-rows/, function (i) {
|
|
48
48
|
return i.remove();
|
|
49
|
-
}); // add empty tracks to rows
|
|
49
|
+
}); // add empty tracks to rows
|
|
50
50
|
|
|
51
51
|
parent.walkDecls(/grid-template-(rows|columns)/, function (trackDecl) {
|
|
52
52
|
if (trackDecl.prop === 'grid-template-rows') {
|
|
53
53
|
hasRows = true;
|
|
54
54
|
var prop = trackDecl.prop,
|
|
55
55
|
value = trackDecl.value;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}),
|
|
67
|
-
value: prefixTrackValue({
|
|
68
|
-
value: value,
|
|
69
|
-
gap: inheritedGap.row
|
|
70
|
-
})
|
|
71
|
-
});
|
|
72
|
-
} else {
|
|
73
|
-
trackDecl.cloneBefore({
|
|
74
|
-
prop: prefixTrackProp({
|
|
75
|
-
prop: prop,
|
|
76
|
-
prefix: prefix
|
|
77
|
-
}),
|
|
78
|
-
value: prefixTrackValue({
|
|
79
|
-
value: value,
|
|
80
|
-
gap: gap.row
|
|
81
|
-
})
|
|
82
|
-
});
|
|
83
|
-
}
|
|
56
|
+
trackDecl.cloneBefore({
|
|
57
|
+
prop: prefixTrackProp({
|
|
58
|
+
prop: prop,
|
|
59
|
+
prefix: prefix
|
|
60
|
+
}),
|
|
61
|
+
value: prefixTrackValue({
|
|
62
|
+
value: value,
|
|
63
|
+
gap: gap.row
|
|
64
|
+
})
|
|
65
|
+
});
|
|
84
66
|
} else {
|
|
85
67
|
hasColumns = true;
|
|
86
|
-
var _prop = trackDecl.prop,
|
|
87
|
-
_value = trackDecl.value;
|
|
88
|
-
/**
|
|
89
|
-
* we must insert inherited gap values in some cases:
|
|
90
|
-
* if we are inside media query && if we have no grid-gap value
|
|
91
|
-
*/
|
|
92
|
-
|
|
93
|
-
if (inheritedGap) {
|
|
94
|
-
trackDecl.cloneBefore({
|
|
95
|
-
prop: prefixTrackProp({
|
|
96
|
-
prop: _prop,
|
|
97
|
-
prefix: prefix
|
|
98
|
-
}),
|
|
99
|
-
value: prefixTrackValue({
|
|
100
|
-
value: _value,
|
|
101
|
-
gap: inheritedGap.column
|
|
102
|
-
})
|
|
103
|
-
});
|
|
104
|
-
} else {
|
|
105
|
-
trackDecl.cloneBefore({
|
|
106
|
-
prop: prefixTrackProp({
|
|
107
|
-
prop: _prop,
|
|
108
|
-
prefix: prefix
|
|
109
|
-
}),
|
|
110
|
-
value: prefixTrackValue({
|
|
111
|
-
value: _value,
|
|
112
|
-
gap: gap.column
|
|
113
|
-
})
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
68
|
}
|
|
117
69
|
});
|
|
118
70
|
var gridRows = getGridRows(decl.value);
|
package/lib/hacks/grid-utils.js
CHANGED
|
@@ -460,7 +460,7 @@ function parseGridTemplatesData(css) {
|
|
|
460
460
|
}
|
|
461
461
|
});
|
|
462
462
|
});
|
|
463
|
-
parsed[index].allAreas = uniq(
|
|
463
|
+
parsed[index].allAreas = uniq([].concat(allAreas, areaNames));
|
|
464
464
|
parsed[index].rules.push({
|
|
465
465
|
hasDuplicates: !hasNoDuplicates,
|
|
466
466
|
params: media.params,
|
|
@@ -795,7 +795,9 @@ function warnIfGridRowColumnExists(decl, result) {
|
|
|
795
795
|
var rule = decl.parent;
|
|
796
796
|
var decls = [];
|
|
797
797
|
rule.walkDecls(/^grid-(row|column)/, function (d) {
|
|
798
|
-
|
|
798
|
+
if (!/-end$/.test(d.prop) && !/^span/.test(d.value)) {
|
|
799
|
+
decls.push(d);
|
|
800
|
+
}
|
|
799
801
|
});
|
|
800
802
|
|
|
801
803
|
if (decls.length > 0) {
|
|
@@ -1002,6 +1004,129 @@ function warnGridGap(_ref13) {
|
|
|
1002
1004
|
decl.warn(result, 'Can not impliment grid-gap without grid-tamplate-columns');
|
|
1003
1005
|
}
|
|
1004
1006
|
}
|
|
1007
|
+
/**
|
|
1008
|
+
* normalize the grid-template-rows/columns values
|
|
1009
|
+
* @param {String} str grid-template-rows/columns value
|
|
1010
|
+
* @return {Array} normalized array with values
|
|
1011
|
+
* @example
|
|
1012
|
+
* let normalized = normalizeRowColumn('1fr repeat(2, 20px 50px) 1fr')
|
|
1013
|
+
* normalized // <= ['1fr', '20px', '50px', '20px', '50px', '1fr']
|
|
1014
|
+
*/
|
|
1015
|
+
|
|
1016
|
+
|
|
1017
|
+
function normalizeRowColumn(str) {
|
|
1018
|
+
var normalized = parser(str).nodes.reduce(function (result, node) {
|
|
1019
|
+
if (node.type === 'function' && node.value === 'repeat') {
|
|
1020
|
+
var key = 'count';
|
|
1021
|
+
|
|
1022
|
+
var _node$nodes$reduce = node.nodes.reduce(function (acc, n) {
|
|
1023
|
+
if (n.type === 'word' && key === 'count') {
|
|
1024
|
+
acc[0] = Math.abs(parseInt(n.value));
|
|
1025
|
+
return acc;
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
if (n.type === 'div' && n.value === ',') {
|
|
1029
|
+
key = 'value';
|
|
1030
|
+
return acc;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
1033
|
+
if (key === 'value') {
|
|
1034
|
+
acc[1] += parser.stringify(n);
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
return acc;
|
|
1038
|
+
}, [0, '']),
|
|
1039
|
+
count = _node$nodes$reduce[0],
|
|
1040
|
+
value = _node$nodes$reduce[1];
|
|
1041
|
+
|
|
1042
|
+
if (count) {
|
|
1043
|
+
for (var i = 0; i < count; i++) {
|
|
1044
|
+
result.push(value);
|
|
1045
|
+
}
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
return result;
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
if (node.type === 'space') {
|
|
1052
|
+
return result;
|
|
1053
|
+
}
|
|
1054
|
+
|
|
1055
|
+
return result.concat(parser.stringify(node));
|
|
1056
|
+
}, []);
|
|
1057
|
+
return normalized;
|
|
1058
|
+
}
|
|
1059
|
+
/**
|
|
1060
|
+
* Autoplace grid items
|
|
1061
|
+
* @param {Declaration} decl
|
|
1062
|
+
* @param {Result} result
|
|
1063
|
+
* @param {Object} gap gap values
|
|
1064
|
+
* @param {String} autoflowValue grid-auto-flow value
|
|
1065
|
+
* @return {void}
|
|
1066
|
+
* @see https://github.com/postcss/autoprefixer/issues/1148
|
|
1067
|
+
*/
|
|
1068
|
+
|
|
1069
|
+
|
|
1070
|
+
function autoplaceGridItems(decl, result, gap, autoflowValue) {
|
|
1071
|
+
if (autoflowValue === void 0) {
|
|
1072
|
+
autoflowValue = 'row';
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
var parent = decl.parent;
|
|
1076
|
+
var rowDecl = parent.nodes.find(function (i) {
|
|
1077
|
+
return i.prop === 'grid-template-rows';
|
|
1078
|
+
});
|
|
1079
|
+
var rows = normalizeRowColumn(rowDecl.value);
|
|
1080
|
+
var columns = normalizeRowColumn(decl.value); // Build array of area names with dummy values. If we have 3 columns and
|
|
1081
|
+
// 2 rows, filledRows will be equal to ['1 2 3', '4 5 6']
|
|
1082
|
+
|
|
1083
|
+
var filledRows = rows.map(function (_, rowIndex) {
|
|
1084
|
+
return Array.from({
|
|
1085
|
+
length: columns.length
|
|
1086
|
+
}, function (v, k) {
|
|
1087
|
+
return k + rowIndex * columns.length + 1;
|
|
1088
|
+
}).join(' ');
|
|
1089
|
+
});
|
|
1090
|
+
var areas = parseGridAreas({
|
|
1091
|
+
rows: filledRows,
|
|
1092
|
+
gap: gap
|
|
1093
|
+
});
|
|
1094
|
+
var keys = Object.keys(areas);
|
|
1095
|
+
var items = keys.map(function (i) {
|
|
1096
|
+
return areas[i];
|
|
1097
|
+
}); // Change the order of cells if grid-auto-flow value is 'column'
|
|
1098
|
+
|
|
1099
|
+
if (autoflowValue.includes('column')) {
|
|
1100
|
+
items = items.sort(function (a, b) {
|
|
1101
|
+
return a.column.start - b.column.start;
|
|
1102
|
+
});
|
|
1103
|
+
} // Insert new rules
|
|
1104
|
+
|
|
1105
|
+
|
|
1106
|
+
items.reverse().forEach(function (item, index) {
|
|
1107
|
+
var column = item.column,
|
|
1108
|
+
row = item.row;
|
|
1109
|
+
var nodeSelector = parent.selectors.map(function (sel) {
|
|
1110
|
+
return sel + (" > *:nth-child(" + (keys.length - index) + ")");
|
|
1111
|
+
}).join(', '); // create new rule
|
|
1112
|
+
|
|
1113
|
+
var node = parent.clone().removeAll(); // change rule selector
|
|
1114
|
+
|
|
1115
|
+
node.selector = nodeSelector; // insert prefixed row/column values
|
|
1116
|
+
|
|
1117
|
+
node.append({
|
|
1118
|
+
prop: '-ms-grid-row',
|
|
1119
|
+
value: row.start
|
|
1120
|
+
});
|
|
1121
|
+
node.append({
|
|
1122
|
+
prop: '-ms-grid-column',
|
|
1123
|
+
value: column.start
|
|
1124
|
+
}); // insert rule
|
|
1125
|
+
|
|
1126
|
+
parent.after(node);
|
|
1127
|
+
});
|
|
1128
|
+
return undefined;
|
|
1129
|
+
}
|
|
1005
1130
|
|
|
1006
1131
|
module.exports = {
|
|
1007
1132
|
parse: parse,
|
|
@@ -1017,5 +1142,6 @@ module.exports = {
|
|
|
1017
1142
|
warnGridGap: warnGridGap,
|
|
1018
1143
|
warnTemplateSelectorNotFound: warnTemplateSelectorNotFound,
|
|
1019
1144
|
warnIfGridRowColumnExists: warnIfGridRowColumnExists,
|
|
1020
|
-
inheritGridGap: inheritGridGap
|
|
1145
|
+
inheritGridGap: inheritGridGap,
|
|
1146
|
+
autoplaceGridItems: autoplaceGridItems
|
|
1021
1147
|
};
|