main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.7 KB
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var UNITLESS_NUMBER_PROPS = [
|
---|
4 | 'animation-iteration-count',
|
---|
5 | 'border-image-outset',
|
---|
6 | 'border-image-slice',
|
---|
7 | 'border-image-width',
|
---|
8 | 'box-flex',
|
---|
9 | 'box-flex-group',
|
---|
10 | 'box-ordinal-group',
|
---|
11 | 'column-count',
|
---|
12 | 'columns',
|
---|
13 | 'flex',
|
---|
14 | 'flex-grow',
|
---|
15 | 'flex-positive',
|
---|
16 | 'flex-shrink',
|
---|
17 | 'flex-negative',
|
---|
18 | 'flex-order',
|
---|
19 | 'grid-row',
|
---|
20 | 'grid-row-end',
|
---|
21 | 'grid-row-span',
|
---|
22 | 'grid-row-start',
|
---|
23 | 'grid-column',
|
---|
24 | 'grid-column-end',
|
---|
25 | 'grid-column-span',
|
---|
26 | 'grid-column-start',
|
---|
27 | 'font-weight',
|
---|
28 | 'line-clamp',
|
---|
29 | 'line-height',
|
---|
30 | 'opacity',
|
---|
31 | 'order',
|
---|
32 | 'orphans',
|
---|
33 | 'tabSize',
|
---|
34 | 'widows',
|
---|
35 | 'z-index',
|
---|
36 | 'zoom',
|
---|
37 |
|
---|
38 | // SVG-related properties
|
---|
39 | 'fill-opacity',
|
---|
40 | 'flood-opacity',
|
---|
41 | 'stop-opacity',
|
---|
42 | 'stroke-dasharray',
|
---|
43 | 'stroke-dashoffset',
|
---|
44 | 'stroke-miterlimit',
|
---|
45 | 'stroke-opacity',
|
---|
46 | 'stroke-width',
|
---|
47 | ];
|
---|
48 |
|
---|
49 | var unitlessCssProperties = {};
|
---|
50 |
|
---|
51 | for (var i = 0; i < UNITLESS_NUMBER_PROPS.length; i++) {
|
---|
52 | var prop = UNITLESS_NUMBER_PROPS[i];
|
---|
53 |
|
---|
54 | unitlessCssProperties[prop] = 1;
|
---|
55 | unitlessCssProperties['-webkit-' + prop] = 1;
|
---|
56 | unitlessCssProperties['-ms-' + prop] = 1;
|
---|
57 | unitlessCssProperties['-moz-' + prop] = 1;
|
---|
58 | unitlessCssProperties['-o-' + prop] = 1;
|
---|
59 | }
|
---|
60 |
|
---|
61 | exports.addon = function (renderer) {
|
---|
62 | var decl = renderer.decl;
|
---|
63 |
|
---|
64 | renderer.decl = function (prop, value) {
|
---|
65 | var str = decl(prop, value);
|
---|
66 |
|
---|
67 | if (typeof value === 'number') {
|
---|
68 | var pos = str.indexOf(':');
|
---|
69 | var propKebab = str.substr(0, pos);
|
---|
70 |
|
---|
71 | if (!unitlessCssProperties[propKebab]) {
|
---|
72 | return decl(prop, value + 'px');
|
---|
73 | }
|
---|
74 | }
|
---|
75 |
|
---|
76 | return str;
|
---|
77 | };
|
---|
78 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.