Skip to content

Commit

Permalink
Adding boolean to keep track of writeCSSDefinition for each layer
Browse files Browse the repository at this point in the history
  • Loading branch information
MiguelCastillo committed Nov 24, 2014
1 parent 53c0f08 commit 35c34c4
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions css-builder.js
Expand Up @@ -108,6 +108,7 @@ define(['require', './normalize'], function(req, normalize) {
var curModule = 0;
var config;

var writeCSSForLayer = true;
var layerBuffer = [];
var cssBuffer = {};

Expand Down Expand Up @@ -163,17 +164,14 @@ define(['require', './normalize'], function(req, normalize) {

if (config.buildCSS != false) {
var style = cssBuffer[moduleName];
var moduleChunks = '';

if (config.writeCSSModule && style) {
moduleChunks += escape(compress(style));

if (writeCSSDefinition) {
if (writeCSSForLayer) {
writeCSSForLayer = false;
write(writeCSSDefinition);
writeCSSDefinition = '';
}

write.asModule(pluginName + '!' + moduleName, 'define(["@writecss"], function(writeCss){\n writeCss("'+ moduleChunks +'");\n})');
write.asModule(pluginName + '!' + moduleName, 'define(["@writecss"], function(writeCss){\n writeCss("'+ escape(compress(style)) +'");\n})');
}
else {
write.asModule(pluginName + '!' + moduleName, 'define(function(){})');
Expand Down Expand Up @@ -212,6 +210,7 @@ define(['require', './normalize'], function(req, normalize) {
}
//clear layer buffer for next layer
layerBuffer = [];
writeCSSForLayer = true;
}

return cssAPI;
Expand Down

0 comments on commit 35c34c4

Please sign in to comment.