Skip to content

Commit

Permalink
feat(parser): create client parser
Browse files Browse the repository at this point in the history
  • Loading branch information
remarkablemark committed Nov 17, 2017
1 parent 9a2d46c commit cd85a31
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/client-parser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
var p = document.createElement('p');

/**
* Parses inline style to object (client).
*
* Example: 'color:red' => { color: 'red' }
*
* @param {String} style
* @return {Object|null}
*/
module.exports = function parseInlineStyleClient(style) {
if (!style || typeof style !== 'string') return null;

p.style = style;
var declarations = p.style;
var output = {};
var property;

for (var i = 0, len = declarations.length; i < len; i++) {
property = declarations[i];
output[property] = declarations[property];
}

return output;
};

0 comments on commit cd85a31

Please sign in to comment.