Skip to content

Commit

Permalink
feat: better kebab case conversion
Browse files Browse the repository at this point in the history
Also added test
  • Loading branch information
TheBosZ authored and streamich committed Sep 18, 2018
1 parent 857bea7 commit 380f65f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
42 changes: 42 additions & 0 deletions addon/__tests__/prefixer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/* eslint-disable */
'use strict';

var env = require('./env');
var create = require('../../index').create;
var addonPrefixer = require('../../addon/prefixer').addon;

function createNano (config) {
var nano = create(config);

addonPrefixer(nano);

return nano;
};

describe('prefixer', function () {
it('installs without crashing', function () {
var nano = createNano();
expect(nano).toBeDefined();
});

it('handles "user-select" correctly', function() {
var nano = createNano();

nano.putRaw = jest.fn();

nano.put('.one', {
'user-select': 'none'
});

var result = nano.putRaw.mock.calls[0][0].replace(/ +(?= )/g,'');
[
'-ms-user-select',
'-moz-user-select',
'-webkit-user-select',
'user-select'
].forEach(function(key) {
expect(result.includes(key)).toBe(true);
});

});
});
3 changes: 3 additions & 0 deletions addon/prefixer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ exports.addon = function (renderer) {

for (var propPrefixed in obj) {
value = obj[propPrefixed];
if (propPrefixed.slice(0, 2) === 'ms') {
propPrefixed = 'M' + propPrefixed.slice(1);
}
propPrefixed = renderer.kebab(propPrefixed);

if (value instanceof Array) {
Expand Down

1 comment on commit 380f65f

@streamich
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build version: 3.2.1-master.90 🤞 master on CircleCI 🎉

Please sign in to comment.