cssstyle 1.4.0 → 2.3.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/{MIT-LICENSE.txt → LICENSE} +0 -0
- package/README.md +7 -19
- package/lib/CSSStyleDeclaration.js +5 -0
- package/lib/CSSStyleDeclaration.test.js +556 -0
- package/lib/allExtraProperties.js +60 -241
- package/lib/allProperties.js +454 -449
- package/lib/allWebkitProperties.js +194 -0
- package/lib/implementedProperties.js +1 -1
- package/lib/parsers.js +33 -8
- package/lib/parsers.test.js +139 -0
- package/lib/properties/fontSize.js +11 -1
- package/lib/properties.js +9 -2
- package/lib/utils/colorSpace.js +21 -0
- package/package.json +27 -30
- package/.eslintignore +0 -3
- package/.eslintrc.js +0 -50
- package/.travis.yml +0 -15
- package/scripts/download_latest_properties.js +0 -88
- package/scripts/generate_implemented_properties.js +0 -61
- package/scripts/generate_properties.js +0 -292
- package/tests/tests.js +0 -669
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This file contains all implemented properties that are not a part of any
|
|
5
|
+
* current specifications or drafts, but are handled by browsers nevertheless.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
module.exports = [
|
|
9
|
+
'animation',
|
|
10
|
+
'animation-delay',
|
|
11
|
+
'animation-direction',
|
|
12
|
+
'animation-duration',
|
|
13
|
+
'animation-fill-mode',
|
|
14
|
+
'animation-iteration-count',
|
|
15
|
+
'animation-name',
|
|
16
|
+
'animation-play-state',
|
|
17
|
+
'animation-timing-function',
|
|
18
|
+
'appearance',
|
|
19
|
+
'aspect-ratio',
|
|
20
|
+
'backface-visibility',
|
|
21
|
+
'background-clip',
|
|
22
|
+
'background-composite',
|
|
23
|
+
'background-origin',
|
|
24
|
+
'background-size',
|
|
25
|
+
'border-after',
|
|
26
|
+
'border-after-color',
|
|
27
|
+
'border-after-style',
|
|
28
|
+
'border-after-width',
|
|
29
|
+
'border-before',
|
|
30
|
+
'border-before-color',
|
|
31
|
+
'border-before-style',
|
|
32
|
+
'border-before-width',
|
|
33
|
+
'border-end',
|
|
34
|
+
'border-end-color',
|
|
35
|
+
'border-end-style',
|
|
36
|
+
'border-end-width',
|
|
37
|
+
'border-fit',
|
|
38
|
+
'border-horizontal-spacing',
|
|
39
|
+
'border-image',
|
|
40
|
+
'border-radius',
|
|
41
|
+
'border-start',
|
|
42
|
+
'border-start-color',
|
|
43
|
+
'border-start-style',
|
|
44
|
+
'border-start-width',
|
|
45
|
+
'border-vertical-spacing',
|
|
46
|
+
'box-align',
|
|
47
|
+
'box-direction',
|
|
48
|
+
'box-flex',
|
|
49
|
+
'box-flex-group',
|
|
50
|
+
'box-lines',
|
|
51
|
+
'box-ordinal-group',
|
|
52
|
+
'box-orient',
|
|
53
|
+
'box-pack',
|
|
54
|
+
'box-reflect',
|
|
55
|
+
'box-shadow',
|
|
56
|
+
'color-correction',
|
|
57
|
+
'column-axis',
|
|
58
|
+
'column-break-after',
|
|
59
|
+
'column-break-before',
|
|
60
|
+
'column-break-inside',
|
|
61
|
+
'column-count',
|
|
62
|
+
'column-gap',
|
|
63
|
+
'column-rule',
|
|
64
|
+
'column-rule-color',
|
|
65
|
+
'column-rule-style',
|
|
66
|
+
'column-rule-width',
|
|
67
|
+
'columns',
|
|
68
|
+
'column-span',
|
|
69
|
+
'column-width',
|
|
70
|
+
'filter',
|
|
71
|
+
'flex-align',
|
|
72
|
+
'flex-direction',
|
|
73
|
+
'flex-flow',
|
|
74
|
+
'flex-item-align',
|
|
75
|
+
'flex-line-pack',
|
|
76
|
+
'flex-order',
|
|
77
|
+
'flex-pack',
|
|
78
|
+
'flex-wrap',
|
|
79
|
+
'flow-from',
|
|
80
|
+
'flow-into',
|
|
81
|
+
'font-feature-settings',
|
|
82
|
+
'font-kerning',
|
|
83
|
+
'font-size-delta',
|
|
84
|
+
'font-smoothing',
|
|
85
|
+
'font-variant-ligatures',
|
|
86
|
+
'highlight',
|
|
87
|
+
'hyphenate-character',
|
|
88
|
+
'hyphenate-limit-after',
|
|
89
|
+
'hyphenate-limit-before',
|
|
90
|
+
'hyphenate-limit-lines',
|
|
91
|
+
'hyphens',
|
|
92
|
+
'line-align',
|
|
93
|
+
'line-box-contain',
|
|
94
|
+
'line-break',
|
|
95
|
+
'line-clamp',
|
|
96
|
+
'line-grid',
|
|
97
|
+
'line-snap',
|
|
98
|
+
'locale',
|
|
99
|
+
'logical-height',
|
|
100
|
+
'logical-width',
|
|
101
|
+
'margin-after',
|
|
102
|
+
'margin-after-collapse',
|
|
103
|
+
'margin-before',
|
|
104
|
+
'margin-before-collapse',
|
|
105
|
+
'margin-bottom-collapse',
|
|
106
|
+
'margin-collapse',
|
|
107
|
+
'margin-end',
|
|
108
|
+
'margin-start',
|
|
109
|
+
'margin-top-collapse',
|
|
110
|
+
'marquee',
|
|
111
|
+
'marquee-direction',
|
|
112
|
+
'marquee-increment',
|
|
113
|
+
'marquee-repetition',
|
|
114
|
+
'marquee-speed',
|
|
115
|
+
'marquee-style',
|
|
116
|
+
'mask',
|
|
117
|
+
'mask-attachment',
|
|
118
|
+
'mask-box-image',
|
|
119
|
+
'mask-box-image-outset',
|
|
120
|
+
'mask-box-image-repeat',
|
|
121
|
+
'mask-box-image-slice',
|
|
122
|
+
'mask-box-image-source',
|
|
123
|
+
'mask-box-image-width',
|
|
124
|
+
'mask-clip',
|
|
125
|
+
'mask-composite',
|
|
126
|
+
'mask-image',
|
|
127
|
+
'mask-origin',
|
|
128
|
+
'mask-position',
|
|
129
|
+
'mask-position-x',
|
|
130
|
+
'mask-position-y',
|
|
131
|
+
'mask-repeat',
|
|
132
|
+
'mask-repeat-x',
|
|
133
|
+
'mask-repeat-y',
|
|
134
|
+
'mask-size',
|
|
135
|
+
'match-nearest-mail-blockquote-color',
|
|
136
|
+
'max-logical-height',
|
|
137
|
+
'max-logical-width',
|
|
138
|
+
'min-logical-height',
|
|
139
|
+
'min-logical-width',
|
|
140
|
+
'nbsp-mode',
|
|
141
|
+
'overflow-scrolling',
|
|
142
|
+
'padding-after',
|
|
143
|
+
'padding-before',
|
|
144
|
+
'padding-end',
|
|
145
|
+
'padding-start',
|
|
146
|
+
'perspective',
|
|
147
|
+
'perspective-origin',
|
|
148
|
+
'perspective-origin-x',
|
|
149
|
+
'perspective-origin-y',
|
|
150
|
+
'print-color-adjust',
|
|
151
|
+
'region-break-after',
|
|
152
|
+
'region-break-before',
|
|
153
|
+
'region-break-inside',
|
|
154
|
+
'region-overflow',
|
|
155
|
+
'rtl-ordering',
|
|
156
|
+
'svg-shadow',
|
|
157
|
+
'tap-highlight-color',
|
|
158
|
+
'text-combine',
|
|
159
|
+
'text-decorations-in-effect',
|
|
160
|
+
'text-emphasis',
|
|
161
|
+
'text-emphasis-color',
|
|
162
|
+
'text-emphasis-position',
|
|
163
|
+
'text-emphasis-style',
|
|
164
|
+
'text-fill-color',
|
|
165
|
+
'text-orientation',
|
|
166
|
+
'text-security',
|
|
167
|
+
'text-size-adjust',
|
|
168
|
+
'text-stroke',
|
|
169
|
+
'text-stroke-color',
|
|
170
|
+
'text-stroke-width',
|
|
171
|
+
'transform',
|
|
172
|
+
'transform-origin',
|
|
173
|
+
'transform-origin-x',
|
|
174
|
+
'transform-origin-y',
|
|
175
|
+
'transform-origin-z',
|
|
176
|
+
'transform-style',
|
|
177
|
+
'transition',
|
|
178
|
+
'transition-delay',
|
|
179
|
+
'transition-duration',
|
|
180
|
+
'transition-property',
|
|
181
|
+
'transition-timing-function',
|
|
182
|
+
'user-drag',
|
|
183
|
+
'user-modify',
|
|
184
|
+
'user-select',
|
|
185
|
+
'wrap',
|
|
186
|
+
'wrap-flow',
|
|
187
|
+
'wrap-margin',
|
|
188
|
+
'wrap-padding',
|
|
189
|
+
'wrap-shape-inside',
|
|
190
|
+
'wrap-shape-outside',
|
|
191
|
+
'wrap-through',
|
|
192
|
+
'writing-mode',
|
|
193
|
+
'zoom',
|
|
194
|
+
].map(prop => 'webkit-' + prop);
|
package/lib/parsers.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
'use strict';
|
|
6
6
|
|
|
7
7
|
const namedColors = require('./named_colors.json');
|
|
8
|
+
const { hslToRgb } = require('./utils/colorSpace');
|
|
8
9
|
|
|
9
10
|
exports.TYPES = {
|
|
10
11
|
INTEGER: 1,
|
|
@@ -17,18 +18,20 @@ exports.TYPES = {
|
|
|
17
18
|
ANGLE: 8,
|
|
18
19
|
KEYWORD: 9,
|
|
19
20
|
NULL_OR_EMPTY_STR: 10,
|
|
21
|
+
CALC: 11,
|
|
20
22
|
};
|
|
21
23
|
|
|
22
24
|
// rough regular expressions
|
|
23
25
|
var integerRegEx = /^[-+]?[0-9]+$/;
|
|
24
|
-
var numberRegEx = /^[-+]?[0-9]
|
|
25
|
-
var lengthRegEx = /^(0|[-+]?[0-9]*\.?[0-9]+(in|cm|em|mm|pt|pc|px|ex|rem|vh|vw))$/;
|
|
26
|
+
var numberRegEx = /^[-+]?[0-9]*\.?[0-9]+$/;
|
|
27
|
+
var lengthRegEx = /^(0|[-+]?[0-9]*\.?[0-9]+(in|cm|em|mm|pt|pc|px|ex|rem|vh|vw|ch))$/;
|
|
26
28
|
var percentRegEx = /^[-+]?[0-9]*\.?[0-9]+%$/;
|
|
27
29
|
var urlRegEx = /^url\(\s*([^)]*)\s*\)$/;
|
|
28
30
|
var stringRegEx = /^("[^"]*"|'[^']*')$/;
|
|
29
|
-
var colorRegEx1 = /^#
|
|
31
|
+
var colorRegEx1 = /^#([0-9a-fA-F]{3,4}){1,2}$/;
|
|
30
32
|
var colorRegEx2 = /^rgb\(([^)]*)\)$/;
|
|
31
33
|
var colorRegEx3 = /^rgba\(([^)]*)\)$/;
|
|
34
|
+
var calcRegEx = /^calc\(([^)]*)\)$/;
|
|
32
35
|
var colorRegEx4 = /^hsla?\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*(,\s*(-?\d+|-?\d*.\d+)\s*)?\)/;
|
|
33
36
|
var angleRegEx = /^([-+]?[0-9]*\.?[0-9]+)(deg|grad|rad)$/;
|
|
34
37
|
|
|
@@ -60,6 +63,9 @@ exports.valueType = function valueType(val) {
|
|
|
60
63
|
if (urlRegEx.test(val)) {
|
|
61
64
|
return exports.TYPES.URL;
|
|
62
65
|
}
|
|
66
|
+
if (calcRegEx.test(val)) {
|
|
67
|
+
return exports.TYPES.CALC;
|
|
68
|
+
}
|
|
63
69
|
if (stringRegEx.test(val)) {
|
|
64
70
|
return exports.TYPES.STRING;
|
|
65
71
|
}
|
|
@@ -69,6 +75,7 @@ exports.valueType = function valueType(val) {
|
|
|
69
75
|
if (colorRegEx1.test(val)) {
|
|
70
76
|
return exports.TYPES.COLOR;
|
|
71
77
|
}
|
|
78
|
+
|
|
72
79
|
var res = colorRegEx2.exec(val);
|
|
73
80
|
var parts;
|
|
74
81
|
if (res !== null) {
|
|
@@ -92,7 +99,7 @@ exports.valueType = function valueType(val) {
|
|
|
92
99
|
}
|
|
93
100
|
if (
|
|
94
101
|
parts.slice(0, 3).every(percentRegEx.test.bind(percentRegEx)) ||
|
|
95
|
-
parts.every(integerRegEx.test.bind(integerRegEx))
|
|
102
|
+
parts.slice(0, 3).every(integerRegEx.test.bind(integerRegEx))
|
|
96
103
|
) {
|
|
97
104
|
if (numberRegEx.test(parts[3])) {
|
|
98
105
|
return exports.TYPES.COLOR;
|
|
@@ -200,6 +207,11 @@ exports.parsePercent = function parsePercent(val) {
|
|
|
200
207
|
|
|
201
208
|
// either a length or a percent
|
|
202
209
|
exports.parseMeasurement = function parseMeasurement(val) {
|
|
210
|
+
var type = exports.valueType(val);
|
|
211
|
+
if (type === exports.TYPES.CALC) {
|
|
212
|
+
return val;
|
|
213
|
+
}
|
|
214
|
+
|
|
203
215
|
var length = exports.parseLength(val);
|
|
204
216
|
if (length !== undefined) {
|
|
205
217
|
return length;
|
|
@@ -287,15 +299,26 @@ exports.parseColor = function parseColor(val) {
|
|
|
287
299
|
alpha = 1;
|
|
288
300
|
var parts;
|
|
289
301
|
var res = colorRegEx1.exec(val);
|
|
290
|
-
// is it #aaa
|
|
302
|
+
// is it #aaa, #ababab, #aaaa, #abababaa
|
|
291
303
|
if (res) {
|
|
304
|
+
var defaultHex = val.substr(1);
|
|
292
305
|
var hex = val.substr(1);
|
|
293
|
-
if (hex.length === 3) {
|
|
306
|
+
if (hex.length === 3 || hex.length === 4) {
|
|
294
307
|
hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
|
308
|
+
|
|
309
|
+
if (defaultHex.length === 4) {
|
|
310
|
+
hex = hex + defaultHex[3] + defaultHex[3];
|
|
311
|
+
}
|
|
295
312
|
}
|
|
296
313
|
red = parseInt(hex.substr(0, 2), 16);
|
|
297
314
|
green = parseInt(hex.substr(2, 2), 16);
|
|
298
315
|
blue = parseInt(hex.substr(4, 2), 16);
|
|
316
|
+
if (hex.length === 8) {
|
|
317
|
+
var hexAlpha = hex.substr(6, 2);
|
|
318
|
+
var hexAlphaToRgbaAlpha = Number((parseInt(hexAlpha, 16) / 255).toFixed(3));
|
|
319
|
+
|
|
320
|
+
return 'rgba(' + red + ', ' + green + ', ' + blue + ', ' + hexAlphaToRgbaAlpha + ')';
|
|
321
|
+
}
|
|
299
322
|
return 'rgb(' + red + ', ' + green + ', ' + blue + ')';
|
|
300
323
|
}
|
|
301
324
|
|
|
@@ -367,10 +390,12 @@ exports.parseColor = function parseColor(val) {
|
|
|
367
390
|
if (_alpha && numberRegEx.test(_alpha)) {
|
|
368
391
|
alpha = parseFloat(_alpha);
|
|
369
392
|
}
|
|
393
|
+
|
|
394
|
+
const [r, g, b] = hslToRgb(hue, saturation / 100, lightness / 100);
|
|
370
395
|
if (!_alphaString || alpha === 1) {
|
|
371
|
-
return '
|
|
396
|
+
return 'rgb(' + r + ', ' + g + ', ' + b + ')';
|
|
372
397
|
}
|
|
373
|
-
return '
|
|
398
|
+
return 'rgba(' + r + ', ' + g + ', ' + b + ', ' + alpha + ')';
|
|
374
399
|
}
|
|
375
400
|
|
|
376
401
|
if (type === exports.TYPES.COLOR) {
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const parsers = require('./parsers');
|
|
4
|
+
|
|
5
|
+
describe('valueType', () => {
|
|
6
|
+
it('returns color for red', () => {
|
|
7
|
+
let input = 'red';
|
|
8
|
+
let output = parsers.valueType(input);
|
|
9
|
+
|
|
10
|
+
expect(output).toEqual(parsers.TYPES.COLOR);
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('returns color for #nnnnnn', () => {
|
|
14
|
+
let input = '#fefefe';
|
|
15
|
+
let output = parsers.valueType(input);
|
|
16
|
+
|
|
17
|
+
expect(output).toEqual(parsers.TYPES.COLOR);
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('returns color for rgb(n, n, n)', () => {
|
|
21
|
+
let input = 'rgb(10, 10, 10)';
|
|
22
|
+
let output = parsers.valueType(input);
|
|
23
|
+
|
|
24
|
+
expect(output).toEqual(parsers.TYPES.COLOR);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('returns color for rgb(p, p, p)', () => {
|
|
28
|
+
let input = 'rgb(10%, 10%, 10%)';
|
|
29
|
+
let output = parsers.valueType(input);
|
|
30
|
+
|
|
31
|
+
expect(output).toEqual(parsers.TYPES.COLOR);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('returns color for rgba(n, n, n, n)', () => {
|
|
35
|
+
let input = 'rgba(10, 10, 10, 1)';
|
|
36
|
+
let output = parsers.valueType(input);
|
|
37
|
+
|
|
38
|
+
expect(output).toEqual(parsers.TYPES.COLOR);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('returns color for rgba(n, n, n, n) with decimal alpha', () => {
|
|
42
|
+
let input = 'rgba(10, 10, 10, 0.5)';
|
|
43
|
+
let output = parsers.valueType(input);
|
|
44
|
+
|
|
45
|
+
expect(output).toEqual(parsers.TYPES.COLOR);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('returns color for rgba(p, p, p, n)', () => {
|
|
49
|
+
let input = 'rgba(10%, 10%, 10%, 1)';
|
|
50
|
+
let output = parsers.valueType(input);
|
|
51
|
+
|
|
52
|
+
expect(output).toEqual(parsers.TYPES.COLOR);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('returns color for rgba(p, p, p, n) with decimal alpha', () => {
|
|
56
|
+
let input = 'rgba(10%, 10%, 10%, 0.5)';
|
|
57
|
+
let output = parsers.valueType(input);
|
|
58
|
+
|
|
59
|
+
expect(output).toEqual(parsers.TYPES.COLOR);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('returns length for 100ch', () => {
|
|
63
|
+
let input = '100ch';
|
|
64
|
+
let output = parsers.valueType(input);
|
|
65
|
+
|
|
66
|
+
expect(output).toEqual(parsers.TYPES.LENGTH);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('returns calc from calc(100px * 2)', () => {
|
|
70
|
+
let input = 'calc(100px * 2)';
|
|
71
|
+
let output = parsers.valueType(input);
|
|
72
|
+
|
|
73
|
+
expect(output).toEqual(parsers.TYPES.CALC);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
describe('parseInteger', () => {
|
|
77
|
+
it.todo('test');
|
|
78
|
+
});
|
|
79
|
+
describe('parseNumber', () => {
|
|
80
|
+
it.todo('test');
|
|
81
|
+
});
|
|
82
|
+
describe('parseLength', () => {
|
|
83
|
+
it.todo('test');
|
|
84
|
+
});
|
|
85
|
+
describe('parsePercent', () => {
|
|
86
|
+
it.todo('test');
|
|
87
|
+
});
|
|
88
|
+
describe('parseMeasurement', () => {
|
|
89
|
+
it.todo('test');
|
|
90
|
+
});
|
|
91
|
+
describe('parseUrl', () => {
|
|
92
|
+
it.todo('test');
|
|
93
|
+
});
|
|
94
|
+
describe('parseString', () => {
|
|
95
|
+
it.todo('test');
|
|
96
|
+
});
|
|
97
|
+
describe('parseColor', () => {
|
|
98
|
+
it('should convert hsl to rgb values', () => {
|
|
99
|
+
let input = 'hsla(0, 1%, 2%)';
|
|
100
|
+
let output = parsers.parseColor(input);
|
|
101
|
+
|
|
102
|
+
expect(output).toEqual('rgb(5, 5, 5)');
|
|
103
|
+
});
|
|
104
|
+
it('should convert hsla to rgba values', () => {
|
|
105
|
+
let input = 'hsla(0, 1%, 2%, 0.5)';
|
|
106
|
+
let output = parsers.parseColor(input);
|
|
107
|
+
|
|
108
|
+
expect(output).toEqual('rgba(5, 5, 5, 0.5)');
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it.todo('Add more tests');
|
|
112
|
+
});
|
|
113
|
+
describe('parseAngle', () => {
|
|
114
|
+
it.todo('test');
|
|
115
|
+
});
|
|
116
|
+
describe('parseKeyword', () => {
|
|
117
|
+
it.todo('test');
|
|
118
|
+
});
|
|
119
|
+
describe('dashedToCamelCase', () => {
|
|
120
|
+
it.todo('test');
|
|
121
|
+
});
|
|
122
|
+
describe('shorthandParser', () => {
|
|
123
|
+
it.todo('test');
|
|
124
|
+
});
|
|
125
|
+
describe('shorthandSetter', () => {
|
|
126
|
+
it.todo('test');
|
|
127
|
+
});
|
|
128
|
+
describe('shorthandGetter', () => {
|
|
129
|
+
it.todo('test');
|
|
130
|
+
});
|
|
131
|
+
describe('implicitSetter', () => {
|
|
132
|
+
it.todo('test');
|
|
133
|
+
});
|
|
134
|
+
describe('subImplicitSetter', () => {
|
|
135
|
+
it.todo('test');
|
|
136
|
+
});
|
|
137
|
+
describe('camelToDashed', () => {
|
|
138
|
+
it.todo('test');
|
|
139
|
+
});
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var TYPES = require('../parsers').TYPES;
|
|
4
4
|
var valueType = require('../parsers').valueType;
|
|
5
|
+
var parseMeasurement = require('../parsers').parseMeasurement;
|
|
5
6
|
|
|
6
7
|
var absoluteSizes = ['xx-small', 'x-small', 'small', 'medium', 'large', 'x-large', 'xx-large'];
|
|
7
8
|
var relativeSizes = ['larger', 'smaller'];
|
|
@@ -16,9 +17,18 @@ module.exports.isValid = function(v) {
|
|
|
16
17
|
);
|
|
17
18
|
};
|
|
18
19
|
|
|
20
|
+
function parse(v) {
|
|
21
|
+
const valueAsString = String(v).toLowerCase();
|
|
22
|
+
const optionalArguments = absoluteSizes.concat(relativeSizes);
|
|
23
|
+
const isOptionalArgument = optionalArguments.some(
|
|
24
|
+
stringValue => stringValue.toLowerCase() === valueAsString
|
|
25
|
+
);
|
|
26
|
+
return isOptionalArgument ? valueAsString : parseMeasurement(v);
|
|
27
|
+
}
|
|
28
|
+
|
|
19
29
|
module.exports.definition = {
|
|
20
30
|
set: function(v) {
|
|
21
|
-
this._setProperty('font-size', v);
|
|
31
|
+
this._setProperty('font-size', parse(v));
|
|
22
32
|
},
|
|
23
33
|
get: function() {
|
|
24
34
|
return this.getPropertyValue('font-size');
|
package/lib/properties.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
// autogenerated -
|
|
3
|
+
// autogenerated - 4/29/2020
|
|
4
4
|
|
|
5
5
|
/*
|
|
6
6
|
*
|
|
@@ -1040,9 +1040,16 @@ fontSize_export_isValid = function (v) {
|
|
|
1040
1040
|
return type === external_dependency_parsers_0.TYPES.LENGTH || type === external_dependency_parsers_0.TYPES.PERCENT || type === external_dependency_parsers_0.TYPES.KEYWORD && fontSize_local_var_absoluteSizes.indexOf(v.toLowerCase()) !== -1 || type === external_dependency_parsers_0.TYPES.KEYWORD && fontSize_local_var_relativeSizes.indexOf(v.toLowerCase()) !== -1;
|
|
1041
1041
|
};
|
|
1042
1042
|
|
|
1043
|
+
function fontSize_local_fn_parse(v) {
|
|
1044
|
+
const valueAsString = String(v).toLowerCase();
|
|
1045
|
+
const optionalArguments = fontSize_local_var_absoluteSizes.concat(fontSize_local_var_relativeSizes);
|
|
1046
|
+
const isOptionalArgument = optionalArguments.some(stringValue => stringValue.toLowerCase() === valueAsString);
|
|
1047
|
+
return isOptionalArgument ? valueAsString : external_dependency_parsers_0.parseMeasurement(v);
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1043
1050
|
fontSize_export_definition = {
|
|
1044
1051
|
set: function (v) {
|
|
1045
|
-
this._setProperty('font-size', v);
|
|
1052
|
+
this._setProperty('font-size', fontSize_local_fn_parse(v));
|
|
1046
1053
|
},
|
|
1047
1054
|
get: function () {
|
|
1048
1055
|
return this.getPropertyValue('font-size');
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const hueToRgb = (t1, t2, hue) => {
|
|
4
|
+
if (hue < 0) hue += 6;
|
|
5
|
+
if (hue >= 6) hue -= 6;
|
|
6
|
+
|
|
7
|
+
if (hue < 1) return (t2 - t1) * hue + t1;
|
|
8
|
+
else if (hue < 3) return t2;
|
|
9
|
+
else if (hue < 4) return (t2 - t1) * (4 - hue) + t1;
|
|
10
|
+
else return t1;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// https://www.w3.org/TR/css-color-4/#hsl-to-rgb
|
|
14
|
+
exports.hslToRgb = (hue, sat, light) => {
|
|
15
|
+
const t2 = light <= 0.5 ? light * (sat + 1) : light + sat - light * sat;
|
|
16
|
+
const t1 = light * 2 - t2;
|
|
17
|
+
const r = hueToRgb(t1, t2, hue + 2);
|
|
18
|
+
const g = hueToRgb(t1, t2, hue);
|
|
19
|
+
const b = hueToRgb(t1, t2, hue - 2);
|
|
20
|
+
return [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
|
|
21
|
+
};
|
package/package.json
CHANGED
|
@@ -6,13 +6,18 @@
|
|
|
6
6
|
"CSSStyleDeclaration",
|
|
7
7
|
"StyleSheet"
|
|
8
8
|
],
|
|
9
|
-
"version": "
|
|
10
|
-
"homepage": "https://github.com/
|
|
9
|
+
"version": "2.3.0",
|
|
10
|
+
"homepage": "https://github.com/jsdom/cssstyle",
|
|
11
11
|
"maintainers": [
|
|
12
12
|
{
|
|
13
13
|
"name": "Jon Sakas",
|
|
14
14
|
"email": "jon.sakas@gmail.com",
|
|
15
15
|
"url": "https://jon.sakas.co/"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "Rafał Ruciński",
|
|
19
|
+
"email": "fatfisz@gmail.com",
|
|
20
|
+
"url": "https://fatfisz.com"
|
|
16
21
|
}
|
|
17
22
|
],
|
|
18
23
|
"contributors": [
|
|
@@ -20,45 +25,33 @@
|
|
|
20
25
|
"name": "Chad Walker",
|
|
21
26
|
"email": "chad@chad-cat-lore-eddie.com",
|
|
22
27
|
"url": "https://github.com/chad3814"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"name": "Rafał Ruciński",
|
|
26
|
-
"email": "fatfisz@gmail.com",
|
|
27
|
-
"url": "https://fatfisz.com"
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"name": "Nikita Vasilyev",
|
|
31
|
-
"email": "me@elv1s.ru"
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
"name": "Davide P. Cervone"
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
"name": "Forbes Lindesay"
|
|
38
28
|
}
|
|
39
29
|
],
|
|
40
|
-
"repository": "
|
|
41
|
-
"bugs": "https://github.com/
|
|
30
|
+
"repository": "jsdom/cssstyle",
|
|
31
|
+
"bugs": "https://github.com/jsdom/cssstyle/issues",
|
|
42
32
|
"directories": {
|
|
43
33
|
"lib": "./lib"
|
|
44
34
|
},
|
|
35
|
+
"files": [
|
|
36
|
+
"lib/"
|
|
37
|
+
],
|
|
45
38
|
"main": "./lib/CSSStyleDeclaration.js",
|
|
46
39
|
"dependencies": {
|
|
47
|
-
"cssom": "0.3.
|
|
40
|
+
"cssom": "~0.3.6"
|
|
48
41
|
},
|
|
49
42
|
"devDependencies": {
|
|
50
43
|
"babel-generator": "~6.26.1",
|
|
51
44
|
"babel-traverse": "~6.26.0",
|
|
52
45
|
"babel-types": "~6.26.0",
|
|
53
46
|
"babylon": "~6.18.0",
|
|
54
|
-
"eslint": "
|
|
55
|
-
"eslint-config-prettier": "
|
|
56
|
-
"eslint-plugin-prettier": "3.0
|
|
57
|
-
"
|
|
47
|
+
"eslint": "~6.0.0",
|
|
48
|
+
"eslint-config-prettier": "~6.0.0",
|
|
49
|
+
"eslint-plugin-prettier": "~3.1.0",
|
|
50
|
+
"jest": "^24.8.0",
|
|
58
51
|
"npm-run-all": "^4.1.5",
|
|
59
|
-
"prettier": "1.
|
|
52
|
+
"prettier": "~1.18.0",
|
|
60
53
|
"request": "^2.88.0",
|
|
61
|
-
"resolve": "~1.
|
|
54
|
+
"resolve": "~1.11.1"
|
|
62
55
|
},
|
|
63
56
|
"scripts": {
|
|
64
57
|
"download": "node ./scripts/download_latest_properties.js && eslint lib/allProperties.js --fix",
|
|
@@ -67,9 +60,13 @@
|
|
|
67
60
|
"generate:properties": "node ./scripts/generate_properties.js",
|
|
68
61
|
"lint": "npm run generate && eslint . --max-warnings 0",
|
|
69
62
|
"lint:fix": "eslint . --fix --max-warnings 0",
|
|
70
|
-
"prepublishOnly": "npm run test
|
|
71
|
-
"test": "npm run generate &&
|
|
72
|
-
"test-ci": "npm run lint && npm run test"
|
|
63
|
+
"prepublishOnly": "npm run lint && npm run test",
|
|
64
|
+
"test": "npm run generate && jest",
|
|
65
|
+
"test-ci": "npm run lint && npm run test && codecov",
|
|
66
|
+
"update-authors": "git log --format=\"%aN <%aE>\" | sort -f | uniq > AUTHORS"
|
|
73
67
|
},
|
|
74
|
-
"license": "MIT"
|
|
68
|
+
"license": "MIT",
|
|
69
|
+
"engines": {
|
|
70
|
+
"node": ">=8"
|
|
71
|
+
}
|
|
75
72
|
}
|
package/.eslintignore
DELETED
package/.eslintrc.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
root: true,
|
|
5
|
-
extends: ['eslint:recommended', 'prettier'],
|
|
6
|
-
parserOptions: {
|
|
7
|
-
ecmaVersion: 2018,
|
|
8
|
-
},
|
|
9
|
-
env: {
|
|
10
|
-
es6: true,
|
|
11
|
-
},
|
|
12
|
-
globals: {
|
|
13
|
-
exports: true,
|
|
14
|
-
module: true,
|
|
15
|
-
require: true,
|
|
16
|
-
window: true,
|
|
17
|
-
},
|
|
18
|
-
plugins: ['prettier'],
|
|
19
|
-
rules: {
|
|
20
|
-
'prettier/prettier': [
|
|
21
|
-
'warn',
|
|
22
|
-
{
|
|
23
|
-
printWidth: 100,
|
|
24
|
-
singleQuote: true,
|
|
25
|
-
trailingComma: 'es5',
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
strict: ['warn', 'global'],
|
|
29
|
-
},
|
|
30
|
-
overrides: [
|
|
31
|
-
{
|
|
32
|
-
files: ['lib/implementedProperties.js', 'lib/properties.js'],
|
|
33
|
-
rules: {
|
|
34
|
-
'prettier/prettier': 'off',
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
files: 'scripts/**/*',
|
|
39
|
-
rules: {
|
|
40
|
-
'no-console': 'off',
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
files: ['scripts/**/*', 'tests/**/*'],
|
|
45
|
-
env: {
|
|
46
|
-
node: true,
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
],
|
|
50
|
-
};
|