Skip to content

Commit

Permalink
feat: first implementation of array addon
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Mar 20, 2018
1 parent cd8a8e7 commit 77f0ad9
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions addon/array.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use strict';

exports.addon = function (renderer) {
if (process.env.NODE_ENV !== 'production') {
require('./__dev__/warnOnMissingDependencies')('rule', renderer, ['put', 'decl']);
}

var decl = renderer.decl;

renderer.decl = function (prop, value) {
var result = decl(prop, value);

if (value instanceof Array) {
var pos = result.indexOf(':');

prop = result.substr(0, pos + 1);

result = prop + value.join(';' + prop) + ';';
}

return result;
};

var put = renderer.put;

renderer.put = function (selector, decls, atrule) {
if (decls instanceof Array) {
decls = renderer.assign.apply(null, decls);
}

return put(selector, decls, atrule);
};
};

0 comments on commit 77f0ad9

Please sign in to comment.