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