Skip to content

Commit

Permalink
feat: add hoistGlobalsAndWrapContext()
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Mar 13, 2018
1 parent b8a4958 commit 364ba2b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lib/hoistGlobalsAndWrapContext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
'use strict';

module.exports = function(styles, selector) {
var global = {};

global[selector] = styles;

for (var key in styles) {
if (key[0] === '@') {
// At-rule.
if (key[1] === 'k') {
// @keyframes
global[key] = styles[key];
} else {
var obj = {};
obj[selector] = styles[key];
global[key] = obj;
}

delete styles[key];
}
}

return global;
};

0 comments on commit 364ba2b

Please sign in to comment.