Skip to content

Commit ee1f96f

Browse files
support for object as props to css-constructor
1 parent 706b902 commit ee1f96f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

api.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,16 @@ let fillProps = (rawCSS, props) => {
5959
let matches = rawCSS.match(re);
6060
if (matches && matches.length) {
6161
for (let match of matches) {
62-
let keyword = match;
62+
let keyword = match, replaceWord, propKeys;
6363
keyword = keyword.replace('{this.props.', '');
6464
keyword = keyword.substring(0, keyword.length-1); // remove }
6565
keyword = keyword.trim();
66-
rawCSS = rawCSS.replace(match, props[keyword]);
66+
replaceWord = props;
67+
propKeys = keyword.split('.');
68+
for (let i = 0; i < propKeys.length; i++) {
69+
replaceWord = replaceWord[propKeys[i]];
70+
}
71+
rawCSS = rawCSS.replace(match, replaceWord);
6772
}
6873
}
6974
return rawCSS;

0 commit comments

Comments
 (0)