We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b9c3d99 commit 04793b0Copy full SHA for 04793b0
index.js
@@ -1,9 +1,23 @@
1
+var parse = require('css/lib/parse');
2
+
3
/**
4
* Parses inline style to object.
5
*
6
+ * Example: 'color:red' => { color: 'red' }
7
+ *
8
* @param {String} style
9
* @return {Object|null}
10
*/
11
module.exports = function parseInlineStyle(style) {
12
if (!style || typeof style !== 'string') return null;
-}
13
14
+ // make sure to wrap declarations in placeholder
15
+ var declarations = parse('p{' + style + '}').stylesheet.rules[0].declarations;
16
+ var output = {};
17
18
+ declarations.forEach(function(declaration) {
19
+ output[declaration.property] = declaration.value;
20
+ });
21
22
+ return output;
23
+};
0 commit comments