Skip to content

Commit

Permalink
Vendor prefixes style keys (wix-incubator#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
nippur72 committed Jun 6, 2016
1 parent 3a713c2 commit 3b0e355
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/reactTemplates.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ function handleStyleProp(val, node, context) {
const pair = i.split(':');

const value = pair.slice(1).join(':').trim();
return _.camelCase(pair[0].trim()) + ' : ' + utils.convertText(node, context, value.trim());
const parsedKey = /(^-moz-)|(^-o-)|(^-webkit-)/ig.test(key) ? _.upperFirst(_.camelCase(key)) : _.camelCase(key);
return parsedKey + ' : ' + utils.convertText(node, context, value.trim());
})
.join(',');
return `{${styleStr}}`;
Expand Down
4 changes: 4 additions & 0 deletions test/data/style-vendor-prefix.rt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<div>
<span style="-moz-transform:2;-ms-transform:2;-o-transform:2;-webkit-transform:2;transform:2"></span>
<span style="-Moz-transform:2;-Ms-transform:2;-O-transform:2;-Webkit-transform:2;Transform:2"></span>
</div>
25 changes: 25 additions & 0 deletions test/data/style-vendor-prefix.rt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
define([
'react',
'lodash'
], function (React, _) {
'use strict';
return function () {
return React.createElement('div', {}, React.createElement('span', {
'style': {
MozTransform: '2',
msTransform: '2',
OTransform: '2',
WebkitTransform: '2',
transform: '2'
}
}), React.createElement('span', {
'style': {
MozTransform: '2',
msTransform: '2',
OTransform: '2',
WebkitTransform: '2',
transform: '2'
}
}));
};
});
2 changes: 1 addition & 1 deletion test/src/rt.valid.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = {
});

test('conversion test', t => {
const files = ['div.rt', 'test.rt', 'repeat.rt', 'repeat-with-index.rt', 'inputs.rt', 'virtual.rt', 'stateless.rt'];
const files = ['div.rt', 'test.rt', 'repeat.rt', 'repeat-with-index.rt', 'inputs.rt', 'virtual.rt', 'stateless.rt', 'style-vendor-prefix.rt'];
testFiles(t, files);
});

Expand Down

0 comments on commit 3b0e355

Please sign in to comment.