Skip to content

Commit 3ca6681

Browse files
author
Ian Vieira
committed
refactor: Changes to meet projects requirements
1 parent 10ff149 commit 3ca6681

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

lib/attributes-to-props.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
var utilities = require('./utilities');
77
var propertyConfig = require('./property-config');
8-
var parser = require('style-to-object');
8+
var styleToObject = require('style-to-object');
99
var config = propertyConfig.config;
1010
var isCustomAttribute = propertyConfig.HTMLDOMPropertyConfig.isCustomAttribute;
1111

@@ -66,8 +66,11 @@ function cssToJs(style) {
6666

6767
var styleObj = {};
6868

69-
parser(style, function(propName, propValue) {
70-
styleObj[utilities.camelCase(propName)] = propValue;
69+
styleToObject(style, function(propName, propValue) {
70+
// Check if it's not a comment node
71+
if (propName && propValue) {
72+
styleObj[utilities.camelCase(propName)] = propValue;
73+
}
7174
});
7275

7376
return styleObj;

lib/utilities.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
'use strict';
22

3+
var _hyphenPattern = /-(.)/g;
4+
35
/**
46
* Convert a string to camel case.
57
*
68
* @param {String} string - The string.
79
* @return {String}
810
*/
9-
10-
var _hyphenPattern = /-(.)/g;
11-
1211
function camelCase(string) {
1312
if (typeof string !== 'string') { // null is an object
1413
throw new TypeError('First argument must be a string');

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"dependencies": {
3232
"html-dom-parser": "0.1.2",
3333
"react-dom-core": "0.0.2",
34-
"style-to-object": "^0.2.0"
34+
"style-to-object": "0.2.0"
3535
},
3636
"devDependencies": {
3737
"coveralls": "^2.13.1",

0 commit comments

Comments
 (0)