Skip to content

Commit 380f65f

Browse files
TheBosZstreamich
authored andcommitted
feat: better kebab case conversion
Also added test
1 parent 857bea7 commit 380f65f

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

addon/__tests__/prefixer.test.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* eslint-disable */
2+
'use strict';
3+
4+
var env = require('./env');
5+
var create = require('../../index').create;
6+
var addonPrefixer = require('../../addon/prefixer').addon;
7+
8+
function createNano (config) {
9+
var nano = create(config);
10+
11+
addonPrefixer(nano);
12+
13+
return nano;
14+
};
15+
16+
describe('prefixer', function () {
17+
it('installs without crashing', function () {
18+
var nano = createNano();
19+
expect(nano).toBeDefined();
20+
});
21+
22+
it('handles "user-select" correctly', function() {
23+
var nano = createNano();
24+
25+
nano.putRaw = jest.fn();
26+
27+
nano.put('.one', {
28+
'user-select': 'none'
29+
});
30+
31+
var result = nano.putRaw.mock.calls[0][0].replace(/ +(?= )/g,'');
32+
[
33+
'-ms-user-select',
34+
'-moz-user-select',
35+
'-webkit-user-select',
36+
'user-select'
37+
].forEach(function(key) {
38+
expect(result.includes(key)).toBe(true);
39+
});
40+
41+
});
42+
});

addon/prefixer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ exports.addon = function (renderer) {
2424

2525
for (var propPrefixed in obj) {
2626
value = obj[propPrefixed];
27+
if (propPrefixed.slice(0, 2) === 'ms') {
28+
propPrefixed = 'M' + propPrefixed.slice(1);
29+
}
2730
propPrefixed = renderer.kebab(propPrefixed);
2831

2932
if (value instanceof Array) {

0 commit comments

Comments
 (0)