diff --git a/index.js b/index.js index c472d174..697174de 100644 --- a/index.js +++ b/index.js @@ -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); } @@ -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;