Skip to content

Commit

Permalink
fix: make precedence of top level rules higher
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Apr 22, 2018
1 parent d02047e commit 3ae7050
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,13 @@ exports.create = function (config) {
renderer.put = function (selector, decls, atrule) {
var str = '';
var prop, value;
var postponed = [];

for (prop in decls) {
value = decls[prop];

if ((value instanceof Object) && !(value instanceof Array)) {
if (prop[0] === '@') {
renderer.putAt(selector, value, prop);
} else {
renderer.put(renderer.selector(selector, prop), value, atrule);
}
postponed.push([value, prop]);
} else {
str += renderer.decl(prop, value, selector, atrule);
}
Expand All @@ -87,6 +84,17 @@ exports.create = function (config) {
str = selector + '{' + str + '}';
renderer.putRaw(atrule ? atrule + '{' + str + '}' : str);
}

for (var i = 0; i < postponed.length; i++) {
prop = postponed[i][0];
value = postponed[i][1];

if (prop[0] === '@') {
renderer.putAt(selector, prop, value);
} else {
renderer.put(renderer.selector(selector, prop), value, atrule);
}
}
};

renderer.putAt = renderer.put;
Expand Down

0 comments on commit 3ae7050

Please sign in to comment.