1 | module.exports = (el, $) => {
|
2 | let i;
|
3 | let style = [];
|
4 |
|
5 | for (i in el.styleProps) {
|
6 |
|
7 |
|
8 | if (typeof el.styleProps[i].selector.spec !== 'undefined') {
|
9 | if (el.styleProps[i].selector.spec[0] === 2) {
|
10 | el.styleProps[i].value += ' !important';
|
11 | }
|
12 | }
|
13 | style.push(`${el.styleProps[i].prop}: ${el.styleProps[i].value.replace(/["]/g, '\'')};`);
|
14 | }
|
15 |
|
16 |
|
17 | style = style.sort((a, b) => {
|
18 | const aProp = a.split(':')[0];
|
19 | const bProp = b.split(':')[0];
|
20 |
|
21 | return (aProp > bProp ? 1 : aProp < bProp ? -1 : 0);
|
22 | });
|
23 |
|
24 | $(el).attr('style', style.join(' '));
|
25 | };
|