autoprefixer 9.8.7 → 10.0.2
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 +999 -0
- package/README.md +0 -3
- package/bin/autoprefixer +11 -11
- package/data/prefixes.js +799 -545
- package/lib/at-rule.js +23 -50
- package/lib/autoprefixer.js +108 -97
- package/lib/brackets.js +31 -44
- package/lib/browsers.js +54 -71
- package/lib/declaration.js +122 -178
- package/lib/hacks/align-content.js +24 -54
- package/lib/hacks/align-items.js +23 -53
- package/lib/hacks/align-self.js +32 -60
- package/lib/hacks/animation.js +11 -29
- package/lib/hacks/appearance.js +19 -35
- package/lib/hacks/backdrop-filter.js +16 -31
- package/lib/hacks/background-clip.js +19 -36
- package/lib/hacks/background-size.js +16 -31
- package/lib/hacks/block-logical.js +28 -36
- package/lib/hacks/border-image.js +9 -27
- package/lib/hacks/border-radius.js +22 -44
- package/lib/hacks/break-props.js +38 -51
- package/lib/hacks/color-adjust.js +11 -30
- package/lib/hacks/cross-fade.js +29 -48
- package/lib/hacks/display-flex.js +32 -61
- package/lib/hacks/display-grid.js +12 -32
- package/lib/hacks/filter-value.js +8 -25
- package/lib/hacks/filter.js +13 -27
- package/lib/hacks/flex-basis.js +21 -54
- package/lib/hacks/flex-direction.js +41 -77
- package/lib/hacks/flex-flow.js +33 -61
- package/lib/hacks/flex-grow.js +16 -43
- package/lib/hacks/flex-shrink.js +21 -54
- package/lib/hacks/flex-spec.js +7 -10
- package/lib/hacks/flex-wrap.js +11 -32
- package/lib/hacks/flex.js +27 -58
- package/lib/hacks/fullscreen.js +10 -30
- package/lib/hacks/gradient.js +240 -330
- package/lib/hacks/grid-area.js +25 -43
- package/lib/hacks/grid-column-align.js +14 -34
- package/lib/hacks/grid-end.js +30 -45
- package/lib/hacks/grid-row-align.js +14 -34
- package/lib/hacks/grid-row-column.js +20 -39
- package/lib/hacks/grid-rows-columns.js +75 -99
- package/lib/hacks/grid-start.js +17 -39
- package/lib/hacks/grid-template-areas.js +59 -76
- package/lib/hacks/grid-template.js +40 -61
- package/lib/hacks/grid-utils.js +686 -716
- package/lib/hacks/image-rendering.js +24 -47
- package/lib/hacks/image-set.js +10 -30
- package/lib/hacks/inline-logical.js +26 -32
- package/lib/hacks/intrinsic.js +40 -53
- package/lib/hacks/justify-content.js +26 -57
- package/lib/hacks/mask-border.js +28 -36
- package/lib/hacks/mask-composite.js +41 -57
- package/lib/hacks/order.js +22 -52
- package/lib/hacks/overscroll-behavior.js +16 -37
- package/lib/hacks/pixelated.js +16 -40
- package/lib/hacks/place-self.js +18 -41
- package/lib/hacks/placeholder-shown.js +9 -28
- package/lib/hacks/placeholder.js +15 -38
- package/lib/hacks/text-decoration-skip-ink.js +14 -29
- package/lib/hacks/text-decoration.js +20 -31
- package/lib/hacks/text-emphasis-position.js +9 -28
- package/lib/hacks/transform-decl.js +43 -69
- package/lib/hacks/user-select.js +19 -27
- package/lib/hacks/writing-mode.js +19 -36
- package/lib/info.js +63 -93
- package/lib/old-selector.js +39 -60
- package/lib/old-value.js +17 -25
- package/lib/prefixer.js +83 -110
- package/lib/prefixes.js +233 -336
- package/lib/processor.js +420 -416
- package/lib/resolution.js +62 -98
- package/lib/selector.js +91 -139
- package/lib/supports.js +194 -246
- package/lib/transition.js +170 -265
- package/lib/utils.js +49 -72
- package/lib/value.js +77 -116
- package/lib/vendor.js +14 -0
- package/package.json +23 -12
package/lib/hacks/gradient.js
CHANGED
|
@@ -1,519 +1,429 @@
|
|
|
1
|
-
|
|
1
|
+
let parser = require('postcss-value-parser')
|
|
2
|
+
let range = require('normalize-range')
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
let OldValue = require('../old-value')
|
|
5
|
+
let Value = require('../value')
|
|
6
|
+
let utils = require('../utils')
|
|
4
7
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
-
|
|
9
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
10
|
-
|
|
11
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
12
|
-
|
|
13
|
-
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _defaults(subClass, superClass); }
|
|
14
|
-
|
|
15
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
|
-
|
|
17
|
-
var parser = require('postcss-value-parser');
|
|
18
|
-
|
|
19
|
-
var range = require('normalize-range');
|
|
20
|
-
|
|
21
|
-
var OldValue = require('../old-value');
|
|
22
|
-
|
|
23
|
-
var Value = require('../value');
|
|
24
|
-
|
|
25
|
-
var utils = require('../utils');
|
|
26
|
-
|
|
27
|
-
var IS_DIRECTION = /top|left|right|bottom/gi;
|
|
28
|
-
|
|
29
|
-
var Gradient = /*#__PURE__*/function (_Value) {
|
|
30
|
-
_inheritsLoose(Gradient, _Value);
|
|
31
|
-
|
|
32
|
-
function Gradient() {
|
|
33
|
-
var _this;
|
|
34
|
-
|
|
35
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
36
|
-
args[_key] = arguments[_key];
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
_this = _Value.call.apply(_Value, [this].concat(args)) || this;
|
|
40
|
-
|
|
41
|
-
_defineProperty(_assertThisInitialized(_this), "directions", {
|
|
42
|
-
top: 'bottom',
|
|
43
|
-
left: 'right',
|
|
44
|
-
bottom: 'top',
|
|
45
|
-
right: 'left'
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
_defineProperty(_assertThisInitialized(_this), "oldDirections", {
|
|
49
|
-
'top': 'left bottom, left top',
|
|
50
|
-
'left': 'right top, left top',
|
|
51
|
-
'bottom': 'left top, left bottom',
|
|
52
|
-
'right': 'left top, right top',
|
|
53
|
-
'top right': 'left bottom, right top',
|
|
54
|
-
'top left': 'right bottom, left top',
|
|
55
|
-
'right top': 'left bottom, right top',
|
|
56
|
-
'right bottom': 'left top, right bottom',
|
|
57
|
-
'bottom right': 'left top, right bottom',
|
|
58
|
-
'bottom left': 'right top, left bottom',
|
|
59
|
-
'left top': 'right bottom, left top',
|
|
60
|
-
'left bottom': 'right top, left bottom'
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
return _this;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
var _proto = Gradient.prototype;
|
|
8
|
+
let IS_DIRECTION = /top|left|right|bottom/gi
|
|
67
9
|
|
|
10
|
+
class Gradient extends Value {
|
|
68
11
|
/**
|
|
69
12
|
* Change degrees for webkit prefix
|
|
70
13
|
*/
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
for (var _iterator = _createForOfIteratorHelperLoose(ast.nodes), _step; !(_step = _iterator()).done;) {
|
|
75
|
-
var node = _step.value;
|
|
76
|
-
|
|
14
|
+
replace (string, prefix) {
|
|
15
|
+
let ast = parser(string)
|
|
16
|
+
for (let node of ast.nodes) {
|
|
77
17
|
if (node.type === 'function' && node.value === this.name) {
|
|
78
|
-
node.nodes = this.newDirection(node.nodes)
|
|
79
|
-
node.nodes = this.normalize(node.nodes)
|
|
80
|
-
|
|
18
|
+
node.nodes = this.newDirection(node.nodes)
|
|
19
|
+
node.nodes = this.normalize(node.nodes)
|
|
81
20
|
if (prefix === '-webkit- old') {
|
|
82
|
-
|
|
83
|
-
|
|
21
|
+
let changes = this.oldWebkit(node)
|
|
84
22
|
if (!changes) {
|
|
85
|
-
return false
|
|
23
|
+
return false
|
|
86
24
|
}
|
|
87
25
|
} else {
|
|
88
|
-
node.nodes = this.convertDirection(node.nodes)
|
|
89
|
-
node.value = prefix + node.value
|
|
26
|
+
node.nodes = this.convertDirection(node.nodes)
|
|
27
|
+
node.value = prefix + node.value
|
|
90
28
|
}
|
|
91
29
|
}
|
|
92
30
|
}
|
|
93
|
-
|
|
94
|
-
return ast.toString();
|
|
31
|
+
return ast.toString()
|
|
95
32
|
}
|
|
33
|
+
|
|
96
34
|
/**
|
|
97
35
|
* Replace first token
|
|
98
36
|
*/
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
_proto.replaceFirst = function replaceFirst(params) {
|
|
102
|
-
for (var _len2 = arguments.length, words = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
103
|
-
words[_key2 - 1] = arguments[_key2];
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
var prefix = words.map(function (i) {
|
|
37
|
+
replaceFirst (params, ...words) {
|
|
38
|
+
let prefix = words.map(i => {
|
|
107
39
|
if (i === ' ') {
|
|
108
|
-
return {
|
|
109
|
-
type: 'space',
|
|
110
|
-
value: i
|
|
111
|
-
};
|
|
40
|
+
return { type: 'space', value: i }
|
|
112
41
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
value: i
|
|
117
|
-
};
|
|
118
|
-
});
|
|
119
|
-
return prefix.concat(params.slice(1));
|
|
42
|
+
return { type: 'word', value: i }
|
|
43
|
+
})
|
|
44
|
+
return prefix.concat(params.slice(1))
|
|
120
45
|
}
|
|
46
|
+
|
|
121
47
|
/**
|
|
122
48
|
* Convert angle unit to deg
|
|
123
49
|
*/
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
var deg = num / full * 360;
|
|
129
|
-
return deg + "deg";
|
|
50
|
+
normalizeUnit (str, full) {
|
|
51
|
+
let num = parseFloat(str)
|
|
52
|
+
let deg = (num / full) * 360
|
|
53
|
+
return `${deg}deg`
|
|
130
54
|
}
|
|
55
|
+
|
|
131
56
|
/**
|
|
132
57
|
* Normalize angle
|
|
133
58
|
*/
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
_proto.normalize = function normalize(nodes) {
|
|
137
|
-
if (!nodes[0]) return nodes;
|
|
59
|
+
normalize (nodes) {
|
|
60
|
+
if (!nodes[0]) return nodes
|
|
138
61
|
|
|
139
62
|
if (/-?\d+(.\d+)?grad/.test(nodes[0].value)) {
|
|
140
|
-
nodes[0].value = this.normalizeUnit(nodes[0].value, 400)
|
|
63
|
+
nodes[0].value = this.normalizeUnit(nodes[0].value, 400)
|
|
141
64
|
} else if (/-?\d+(.\d+)?rad/.test(nodes[0].value)) {
|
|
142
|
-
nodes[0].value = this.normalizeUnit(nodes[0].value, 2 * Math.PI)
|
|
65
|
+
nodes[0].value = this.normalizeUnit(nodes[0].value, 2 * Math.PI)
|
|
143
66
|
} else if (/-?\d+(.\d+)?turn/.test(nodes[0].value)) {
|
|
144
|
-
nodes[0].value = this.normalizeUnit(nodes[0].value, 1)
|
|
67
|
+
nodes[0].value = this.normalizeUnit(nodes[0].value, 1)
|
|
145
68
|
} else if (nodes[0].value.includes('deg')) {
|
|
146
|
-
|
|
147
|
-
num = range.wrap(0, 360, num)
|
|
148
|
-
nodes[0].value = num
|
|
69
|
+
let num = parseFloat(nodes[0].value)
|
|
70
|
+
num = range.wrap(0, 360, num)
|
|
71
|
+
nodes[0].value = `${num}deg`
|
|
149
72
|
}
|
|
150
73
|
|
|
151
74
|
if (nodes[0].value === '0deg') {
|
|
152
|
-
nodes = this.replaceFirst(nodes, 'to', ' ', 'top')
|
|
75
|
+
nodes = this.replaceFirst(nodes, 'to', ' ', 'top')
|
|
153
76
|
} else if (nodes[0].value === '90deg') {
|
|
154
|
-
nodes = this.replaceFirst(nodes, 'to', ' ', 'right')
|
|
77
|
+
nodes = this.replaceFirst(nodes, 'to', ' ', 'right')
|
|
155
78
|
} else if (nodes[0].value === '180deg') {
|
|
156
|
-
nodes = this.replaceFirst(nodes, 'to', ' ', 'bottom')
|
|
79
|
+
nodes = this.replaceFirst(nodes, 'to', ' ', 'bottom')
|
|
157
80
|
} else if (nodes[0].value === '270deg') {
|
|
158
|
-
nodes = this.replaceFirst(nodes, 'to', ' ', 'left')
|
|
81
|
+
nodes = this.replaceFirst(nodes, 'to', ' ', 'left')
|
|
159
82
|
}
|
|
160
83
|
|
|
161
|
-
return nodes
|
|
84
|
+
return nodes
|
|
162
85
|
}
|
|
86
|
+
|
|
163
87
|
/**
|
|
164
88
|
* Replace old direction to new
|
|
165
89
|
*/
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
_proto.newDirection = function newDirection(params) {
|
|
90
|
+
newDirection (params) {
|
|
169
91
|
if (params[0].value === 'to') {
|
|
170
|
-
return params
|
|
92
|
+
return params
|
|
171
93
|
}
|
|
172
|
-
|
|
173
|
-
IS_DIRECTION.lastIndex = 0; // reset search index of global regexp
|
|
174
|
-
|
|
94
|
+
IS_DIRECTION.lastIndex = 0 // reset search index of global regexp
|
|
175
95
|
if (!IS_DIRECTION.test(params[0].value)) {
|
|
176
|
-
return params
|
|
96
|
+
return params
|
|
177
97
|
}
|
|
178
98
|
|
|
179
|
-
params.unshift(
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
99
|
+
params.unshift(
|
|
100
|
+
{
|
|
101
|
+
type: 'word',
|
|
102
|
+
value: 'to'
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
type: 'space',
|
|
106
|
+
value: ' '
|
|
107
|
+
}
|
|
108
|
+
)
|
|
186
109
|
|
|
187
|
-
for (
|
|
110
|
+
for (let i = 2; i < params.length; i++) {
|
|
188
111
|
if (params[i].type === 'div') {
|
|
189
|
-
break
|
|
112
|
+
break
|
|
190
113
|
}
|
|
191
|
-
|
|
192
114
|
if (params[i].type === 'word') {
|
|
193
|
-
params[i].value = this.revertDirection(params[i].value)
|
|
115
|
+
params[i].value = this.revertDirection(params[i].value)
|
|
194
116
|
}
|
|
195
117
|
}
|
|
196
118
|
|
|
197
|
-
return params
|
|
119
|
+
return params
|
|
198
120
|
}
|
|
121
|
+
|
|
199
122
|
/**
|
|
200
123
|
* Look for at word
|
|
201
124
|
*/
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
var state = 'before';
|
|
206
|
-
|
|
207
|
-
for (var _iterator2 = _createForOfIteratorHelperLoose(params), _step2; !(_step2 = _iterator2()).done;) {
|
|
208
|
-
var param = _step2.value;
|
|
209
|
-
|
|
125
|
+
isRadial (params) {
|
|
126
|
+
let state = 'before'
|
|
127
|
+
for (let param of params) {
|
|
210
128
|
if (state === 'before' && param.type === 'space') {
|
|
211
|
-
state = 'at'
|
|
129
|
+
state = 'at'
|
|
212
130
|
} else if (state === 'at' && param.value === 'at') {
|
|
213
|
-
state = 'after'
|
|
131
|
+
state = 'after'
|
|
214
132
|
} else if (state === 'after' && param.type === 'space') {
|
|
215
|
-
return true
|
|
133
|
+
return true
|
|
216
134
|
} else if (param.type === 'div') {
|
|
217
|
-
break
|
|
135
|
+
break
|
|
218
136
|
} else {
|
|
219
|
-
state = 'before'
|
|
137
|
+
state = 'before'
|
|
220
138
|
}
|
|
221
139
|
}
|
|
222
|
-
|
|
223
|
-
return false;
|
|
140
|
+
return false
|
|
224
141
|
}
|
|
142
|
+
|
|
225
143
|
/**
|
|
226
144
|
* Change new direction to old
|
|
227
145
|
*/
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
_proto.convertDirection = function convertDirection(params) {
|
|
146
|
+
convertDirection (params) {
|
|
231
147
|
if (params.length > 0) {
|
|
232
148
|
if (params[0].value === 'to') {
|
|
233
|
-
this.fixDirection(params)
|
|
149
|
+
this.fixDirection(params)
|
|
234
150
|
} else if (params[0].value.includes('deg')) {
|
|
235
|
-
this.fixAngle(params)
|
|
151
|
+
this.fixAngle(params)
|
|
236
152
|
} else if (this.isRadial(params)) {
|
|
237
|
-
this.fixRadial(params)
|
|
153
|
+
this.fixRadial(params)
|
|
238
154
|
}
|
|
239
155
|
}
|
|
240
|
-
|
|
241
|
-
return params;
|
|
156
|
+
return params
|
|
242
157
|
}
|
|
158
|
+
|
|
243
159
|
/**
|
|
244
160
|
* Replace `to top left` to `bottom right`
|
|
245
161
|
*/
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
_proto.fixDirection = function fixDirection(params) {
|
|
249
|
-
params.splice(0, 2);
|
|
250
|
-
|
|
251
|
-
for (var _iterator3 = _createForOfIteratorHelperLoose(params), _step3; !(_step3 = _iterator3()).done;) {
|
|
252
|
-
var param = _step3.value;
|
|
162
|
+
fixDirection (params) {
|
|
163
|
+
params.splice(0, 2)
|
|
253
164
|
|
|
165
|
+
for (let param of params) {
|
|
254
166
|
if (param.type === 'div') {
|
|
255
|
-
break
|
|
167
|
+
break
|
|
256
168
|
}
|
|
257
|
-
|
|
258
169
|
if (param.type === 'word') {
|
|
259
|
-
param.value = this.revertDirection(param.value)
|
|
170
|
+
param.value = this.revertDirection(param.value)
|
|
260
171
|
}
|
|
261
172
|
}
|
|
262
173
|
}
|
|
174
|
+
|
|
263
175
|
/**
|
|
264
176
|
* Add 90 degrees
|
|
265
177
|
*/
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
first =
|
|
271
|
-
|
|
272
|
-
first = this.roundFloat(first, 3);
|
|
273
|
-
params[0].value = first + "deg";
|
|
178
|
+
fixAngle (params) {
|
|
179
|
+
let first = params[0].value
|
|
180
|
+
first = parseFloat(first)
|
|
181
|
+
first = Math.abs(450 - first) % 360
|
|
182
|
+
first = this.roundFloat(first, 3)
|
|
183
|
+
params[0].value = `${first}deg`
|
|
274
184
|
}
|
|
185
|
+
|
|
275
186
|
/**
|
|
276
187
|
* Fix radial direction syntax
|
|
277
188
|
*/
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
var second = [];
|
|
283
|
-
var a, b, c, i, next;
|
|
189
|
+
fixRadial (params) {
|
|
190
|
+
let first = []
|
|
191
|
+
let second = []
|
|
192
|
+
let a, b, c, i, next
|
|
284
193
|
|
|
285
194
|
for (i = 0; i < params.length - 2; i++) {
|
|
286
|
-
a = params[i]
|
|
287
|
-
b = params[i + 1]
|
|
288
|
-
c = params[i + 2]
|
|
289
|
-
|
|
195
|
+
a = params[i]
|
|
196
|
+
b = params[i + 1]
|
|
197
|
+
c = params[i + 2]
|
|
290
198
|
if (a.type === 'space' && b.value === 'at' && c.type === 'space') {
|
|
291
|
-
next = i + 3
|
|
292
|
-
break
|
|
199
|
+
next = i + 3
|
|
200
|
+
break
|
|
293
201
|
} else {
|
|
294
|
-
first.push(a)
|
|
202
|
+
first.push(a)
|
|
295
203
|
}
|
|
296
204
|
}
|
|
297
205
|
|
|
298
|
-
|
|
299
|
-
|
|
206
|
+
let div
|
|
300
207
|
for (i = next; i < params.length; i++) {
|
|
301
208
|
if (params[i].type === 'div') {
|
|
302
|
-
div = params[i]
|
|
303
|
-
break
|
|
209
|
+
div = params[i]
|
|
210
|
+
break
|
|
304
211
|
} else {
|
|
305
|
-
second.push(params[i])
|
|
212
|
+
second.push(params[i])
|
|
306
213
|
}
|
|
307
214
|
}
|
|
308
215
|
|
|
309
|
-
params.splice
|
|
310
|
-
}
|
|
216
|
+
params.splice(0, i, ...second, div, ...first)
|
|
217
|
+
}
|
|
311
218
|
|
|
312
|
-
|
|
313
|
-
return
|
|
219
|
+
revertDirection (word) {
|
|
220
|
+
return Gradient.directions[word.toLowerCase()] || word
|
|
314
221
|
}
|
|
222
|
+
|
|
315
223
|
/**
|
|
316
224
|
* Round float and save digits under dot
|
|
317
225
|
*/
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
_proto.roundFloat = function roundFloat(_float, digits) {
|
|
321
|
-
return parseFloat(_float.toFixed(digits));
|
|
226
|
+
roundFloat (float, digits) {
|
|
227
|
+
return parseFloat(float.toFixed(digits))
|
|
322
228
|
}
|
|
229
|
+
|
|
323
230
|
/**
|
|
324
231
|
* Convert to old webkit syntax
|
|
325
232
|
*/
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
var nodes = node.nodes;
|
|
330
|
-
var string = parser.stringify(node.nodes);
|
|
233
|
+
oldWebkit (node) {
|
|
234
|
+
let { nodes } = node
|
|
235
|
+
let string = parser.stringify(node.nodes)
|
|
331
236
|
|
|
332
237
|
if (this.name !== 'linear-gradient') {
|
|
333
|
-
return false
|
|
238
|
+
return false
|
|
334
239
|
}
|
|
335
|
-
|
|
336
240
|
if (nodes[0] && nodes[0].value.includes('deg')) {
|
|
337
|
-
return false
|
|
241
|
+
return false
|
|
338
242
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
243
|
+
if (
|
|
244
|
+
string.includes('px') ||
|
|
245
|
+
string.includes('-corner') ||
|
|
246
|
+
string.includes('-side')
|
|
247
|
+
) {
|
|
248
|
+
return false
|
|
342
249
|
}
|
|
343
250
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
var i = _step4.value;
|
|
348
|
-
params[params.length - 1].push(i);
|
|
349
|
-
|
|
251
|
+
let params = [[]]
|
|
252
|
+
for (let i of nodes) {
|
|
253
|
+
params[params.length - 1].push(i)
|
|
350
254
|
if (i.type === 'div' && i.value === ',') {
|
|
351
|
-
params.push([])
|
|
255
|
+
params.push([])
|
|
352
256
|
}
|
|
353
257
|
}
|
|
354
258
|
|
|
355
|
-
this.oldDirection(params)
|
|
356
|
-
this.colorStops(params)
|
|
357
|
-
node.nodes = [];
|
|
259
|
+
this.oldDirection(params)
|
|
260
|
+
this.colorStops(params)
|
|
358
261
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
node.nodes = node.nodes.concat(param)
|
|
262
|
+
node.nodes = []
|
|
263
|
+
for (let param of params) {
|
|
264
|
+
node.nodes = node.nodes.concat(param)
|
|
362
265
|
}
|
|
363
266
|
|
|
364
|
-
node.nodes.unshift(
|
|
365
|
-
type: 'word',
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
node.value = '-webkit-gradient'
|
|
369
|
-
|
|
267
|
+
node.nodes.unshift(
|
|
268
|
+
{ type: 'word', value: 'linear' },
|
|
269
|
+
this.cloneDiv(node.nodes)
|
|
270
|
+
)
|
|
271
|
+
node.value = '-webkit-gradient'
|
|
272
|
+
|
|
273
|
+
return true
|
|
370
274
|
}
|
|
275
|
+
|
|
371
276
|
/**
|
|
372
277
|
* Change direction syntax to old webkit
|
|
373
278
|
*/
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
_proto.oldDirection = function oldDirection(params) {
|
|
377
|
-
var div = this.cloneDiv(params[0]);
|
|
279
|
+
oldDirection (params) {
|
|
280
|
+
let div = this.cloneDiv(params[0])
|
|
378
281
|
|
|
379
282
|
if (params[0][0].value !== 'to') {
|
|
380
|
-
return params.unshift([
|
|
381
|
-
type: 'word',
|
|
382
|
-
|
|
383
|
-
|
|
283
|
+
return params.unshift([
|
|
284
|
+
{ type: 'word', value: Gradient.oldDirections.bottom },
|
|
285
|
+
div
|
|
286
|
+
])
|
|
384
287
|
} else {
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
for (var _iterator5 = _createForOfIteratorHelperLoose(params[0].slice(2)), _step5; !(_step5 = _iterator5()).done;) {
|
|
388
|
-
var node = _step5.value;
|
|
389
|
-
|
|
288
|
+
let words = []
|
|
289
|
+
for (let node of params[0].slice(2)) {
|
|
390
290
|
if (node.type === 'word') {
|
|
391
|
-
words.push(node.value.toLowerCase())
|
|
291
|
+
words.push(node.value.toLowerCase())
|
|
392
292
|
}
|
|
393
293
|
}
|
|
394
294
|
|
|
395
|
-
words = words.join(' ')
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
}, div];
|
|
401
|
-
return params[0];
|
|
295
|
+
words = words.join(' ')
|
|
296
|
+
let old = Gradient.oldDirections[words] || words
|
|
297
|
+
|
|
298
|
+
params[0] = [{ type: 'word', value: old }, div]
|
|
299
|
+
return params[0]
|
|
402
300
|
}
|
|
403
301
|
}
|
|
302
|
+
|
|
404
303
|
/**
|
|
405
304
|
* Get div token from exists parameters
|
|
406
305
|
*/
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
_proto.cloneDiv = function cloneDiv(params) {
|
|
410
|
-
for (var _iterator6 = _createForOfIteratorHelperLoose(params), _step6; !(_step6 = _iterator6()).done;) {
|
|
411
|
-
var i = _step6.value;
|
|
412
|
-
|
|
306
|
+
cloneDiv (params) {
|
|
307
|
+
for (let i of params) {
|
|
413
308
|
if (i.type === 'div' && i.value === ',') {
|
|
414
|
-
return i
|
|
309
|
+
return i
|
|
415
310
|
}
|
|
416
311
|
}
|
|
417
|
-
|
|
418
|
-
return {
|
|
419
|
-
type: 'div',
|
|
420
|
-
value: ',',
|
|
421
|
-
after: ' '
|
|
422
|
-
};
|
|
312
|
+
return { type: 'div', value: ',', after: ' ' }
|
|
423
313
|
}
|
|
314
|
+
|
|
424
315
|
/**
|
|
425
316
|
* Change colors syntax to old webkit
|
|
426
317
|
*/
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
var pos = void 0;
|
|
434
|
-
var param = params[i];
|
|
435
|
-
var item = void 0;
|
|
436
|
-
|
|
318
|
+
colorStops (params) {
|
|
319
|
+
let result = []
|
|
320
|
+
for (let i = 0; i < params.length; i++) {
|
|
321
|
+
let pos
|
|
322
|
+
let param = params[i]
|
|
323
|
+
let item
|
|
437
324
|
if (i === 0) {
|
|
438
|
-
continue
|
|
325
|
+
continue
|
|
439
326
|
}
|
|
440
327
|
|
|
441
|
-
|
|
442
|
-
|
|
328
|
+
let color = parser.stringify(param[0])
|
|
443
329
|
if (param[1] && param[1].type === 'word') {
|
|
444
|
-
pos = param[1].value
|
|
330
|
+
pos = param[1].value
|
|
445
331
|
} else if (param[2] && param[2].type === 'word') {
|
|
446
|
-
pos = param[2].value
|
|
332
|
+
pos = param[2].value
|
|
447
333
|
}
|
|
448
334
|
|
|
449
|
-
|
|
450
|
-
|
|
335
|
+
let stop
|
|
451
336
|
if (i === 1 && (!pos || pos === '0%')) {
|
|
452
|
-
stop =
|
|
337
|
+
stop = `from(${color})`
|
|
453
338
|
} else if (i === params.length - 1 && (!pos || pos === '100%')) {
|
|
454
|
-
stop =
|
|
339
|
+
stop = `to(${color})`
|
|
455
340
|
} else if (pos) {
|
|
456
|
-
stop =
|
|
341
|
+
stop = `color-stop(${pos}, ${color})`
|
|
457
342
|
} else {
|
|
458
|
-
stop =
|
|
343
|
+
stop = `color-stop(${color})`
|
|
459
344
|
}
|
|
460
345
|
|
|
461
|
-
|
|
462
|
-
params[i] = [{
|
|
463
|
-
type: 'word',
|
|
464
|
-
value: stop
|
|
465
|
-
}];
|
|
466
|
-
|
|
346
|
+
let div = param[param.length - 1]
|
|
347
|
+
params[i] = [{ type: 'word', value: stop }]
|
|
467
348
|
if (div.type === 'div' && div.value === ',') {
|
|
468
|
-
item = params[i].push(div)
|
|
349
|
+
item = params[i].push(div)
|
|
469
350
|
}
|
|
470
|
-
|
|
471
|
-
result.push(item);
|
|
351
|
+
result.push(item)
|
|
472
352
|
}
|
|
473
|
-
|
|
474
|
-
return result;
|
|
353
|
+
return result
|
|
475
354
|
}
|
|
355
|
+
|
|
476
356
|
/**
|
|
477
357
|
* Remove old WebKit gradient too
|
|
478
358
|
*/
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
_proto.old = function old(prefix) {
|
|
359
|
+
old (prefix) {
|
|
482
360
|
if (prefix === '-webkit-') {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
361
|
+
let type = this.name === 'linear-gradient' ? 'linear' : 'radial'
|
|
362
|
+
let string = '-gradient'
|
|
363
|
+
let regexp = utils.regexp(
|
|
364
|
+
`-webkit-(${type}-gradient|gradient\\(\\s*${type})`,
|
|
365
|
+
false
|
|
366
|
+
)
|
|
367
|
+
|
|
368
|
+
return new OldValue(this.name, prefix + this.name, string, regexp)
|
|
487
369
|
} else {
|
|
488
|
-
return
|
|
370
|
+
return super.old(prefix)
|
|
489
371
|
}
|
|
490
372
|
}
|
|
373
|
+
|
|
491
374
|
/**
|
|
492
375
|
* Do not add non-webkit prefixes for list-style and object
|
|
493
376
|
*/
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
_proto.add = function add(decl, prefix) {
|
|
497
|
-
var p = decl.prop;
|
|
498
|
-
|
|
377
|
+
add (decl, prefix) {
|
|
378
|
+
let p = decl.prop
|
|
499
379
|
if (p.includes('mask')) {
|
|
500
380
|
if (prefix === '-webkit-' || prefix === '-webkit- old') {
|
|
501
|
-
return
|
|
381
|
+
return super.add(decl, prefix)
|
|
502
382
|
}
|
|
503
|
-
} else if (
|
|
383
|
+
} else if (
|
|
384
|
+
p === 'list-style' ||
|
|
385
|
+
p === 'list-style-image' ||
|
|
386
|
+
p === 'content'
|
|
387
|
+
) {
|
|
504
388
|
if (prefix === '-webkit-' || prefix === '-webkit- old') {
|
|
505
|
-
return
|
|
389
|
+
return super.add(decl, prefix)
|
|
506
390
|
}
|
|
507
391
|
} else {
|
|
508
|
-
return
|
|
392
|
+
return super.add(decl, prefix)
|
|
509
393
|
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
394
|
+
return undefined
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
Gradient.names = [
|
|
399
|
+
'linear-gradient',
|
|
400
|
+
'repeating-linear-gradient',
|
|
401
|
+
'radial-gradient',
|
|
402
|
+
'repeating-radial-gradient'
|
|
403
|
+
]
|
|
404
|
+
|
|
405
|
+
Gradient.directions = {
|
|
406
|
+
top: 'bottom',
|
|
407
|
+
left: 'right',
|
|
408
|
+
bottom: 'top',
|
|
409
|
+
right: 'left'
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
// Direction to replace
|
|
413
|
+
Gradient.oldDirections = {
|
|
414
|
+
'top': 'left bottom, left top',
|
|
415
|
+
'left': 'right top, left top',
|
|
416
|
+
'bottom': 'left top, left bottom',
|
|
417
|
+
'right': 'left top, right top',
|
|
418
|
+
|
|
419
|
+
'top right': 'left bottom, right top',
|
|
420
|
+
'top left': 'right bottom, left top',
|
|
421
|
+
'right top': 'left bottom, right top',
|
|
422
|
+
'right bottom': 'left top, right bottom',
|
|
423
|
+
'bottom right': 'left top, right bottom',
|
|
424
|
+
'bottom left': 'right top, left bottom',
|
|
425
|
+
'left top': 'right bottom, left top',
|
|
426
|
+
'left bottom': 'right top, left bottom'
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
module.exports = Gradient
|