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