|
5 | 5 | */
|
6 | 6 | var utilities = require('./utilities');
|
7 | 7 | var propertyConfig = require('./property-config');
|
| 8 | +var cssToReactNative = require('css-to-react-native'); |
8 | 9 | var config = propertyConfig.config;
|
9 | 10 | var isCustomAttribute = propertyConfig.HTMLDOMPropertyConfig.isCustomAttribute;
|
10 | 11 |
|
@@ -63,33 +64,16 @@ function cssToJs(style) {
|
63 | 64 | throw new Error('`cssToJs`: first argument must be a string. ');
|
64 | 65 | }
|
65 | 66 |
|
66 |
| - var result = {}; |
67 |
| - // e.g., `color: #f00` |
68 |
| - var declarations = style.split(';'); |
69 |
| - // css property itemized as key and value |
70 |
| - var properties; |
71 |
| - var j; |
72 |
| - var propertiesLen; |
| 67 | + var styles = style.split(';'); |
| 68 | + styles = styles.map(function (style) { |
| 69 | + var parts = style.split(':'); |
| 70 | + var propName = parts[0]; |
| 71 | + parts.shift(); |
| 72 | + var propValue = parts.join(':'); |
| 73 | + return [propName.trim(), propValue.trim()]; |
| 74 | + }); |
73 | 75 |
|
74 |
| - for (var i = 0, declarationsLen = declarations.length; i < declarationsLen; i++) { |
75 |
| - properties = declarations[i].trim().split(':'); |
76 |
| - |
77 |
| - // skip if not a css property |
78 |
| - if (properties.length !== 2) { continue; } |
79 |
| - |
80 |
| - // css property name |
81 |
| - properties[0] = properties[0].trim(); |
82 |
| - // css property value |
83 |
| - properties[1] = properties[1].trim(); |
84 |
| - |
85 |
| - if (properties[0] && properties[1]) { |
86 |
| - for (j = 0, propertiesLen = properties.length; j < propertiesLen; j++) { |
87 |
| - result[utilities.camelCase(properties[0])] = properties[1]; |
88 |
| - } |
89 |
| - } |
90 |
| - } |
91 |
| - |
92 |
| - return result; |
| 76 | + return cssToReactNative.default(styles); |
93 | 77 | }
|
94 | 78 |
|
95 | 79 | /**
|
|
0 commit comments