1 | const cssSelector = require('./styleSelector');
|
2 | const importantSelector = cssSelector('<!important>', [ 2, 0, 0, 0 ]);
|
3 | const property = require('./cssProperty');
|
4 |
|
5 | function getProperty(style, name, selector) {
|
6 | const value = style[name];
|
7 | const sel = style._importants[name] ? importantSelector : selector;
|
8 |
|
9 | return property(name, value, sel);
|
10 | }
|
11 |
|
12 |
|
13 | module.exports = ({ styleProps }, style, selector) => {
|
14 | let i;
|
15 | const l = style.length;
|
16 | let name;
|
17 | let prop;
|
18 | let existing;
|
19 | let winner;
|
20 |
|
21 | for (i = 0; i < l; i++) {
|
22 | name = style[i];
|
23 | prop = getProperty(style, name, selector);
|
24 | existing = styleProps[name];
|
25 |
|
26 | if (existing) {
|
27 | winner = existing.compare(prop);
|
28 |
|
29 | if (winner === prop) {
|
30 | styleProps[name] = prop;
|
31 | }
|
32 | } else {
|
33 | styleProps[name] = prop;
|
34 | }
|
35 | }
|
36 | };
|