diff --git a/lib/carto/renderer.js b/lib/carto/renderer.js
index 07dd281..fd9eea5 100644
--- a/lib/carto/renderer.js
+++ b/lib/carto/renderer.js
@@ -47,7 +47,7 @@ carto.Renderer.prototype.renderMSS = function render(data, callback) {
if (env.benchmark) console.time('Total Style generation');
for (var k = 0, rule, style_name; k < sorted.length; k++) {
rule = sorted[k];
- style_name = 'style-' + (rule.attachment !== '__default__' ? '-' + rule.attachment : '');
+ style_name = 'style' + (rule.attachment !== '__default__' ? '-' + rule.attachment : '');
styles.push(style_name);
var bench_name = '\tStyle "'+style_name+'" (#'+k+') toXML';
if (env.benchmark) console.time(bench_name);
diff --git a/lib/carto/tree/definition.js b/lib/carto/tree/definition.js
index 9f3c2bf..39b79ac 100644
--- a/lib/carto/tree/definition.js
+++ b/lib/carto/tree/definition.js
@@ -81,8 +81,7 @@ function symbolizerList(sym_order) {
}
tree.Definition.prototype.symbolizersToXML = function(env, symbolizers, zoom) {
- var xml = ' \n' + zoom.toXML(env).join('') +
- this.filters.toXML(env);
+ var xml = zoom.toXML(env).join('') + this.filters.toXML(env);
// Sort symbolizers by the index of their first property definition
var sym_order = [], indexes = [];
@@ -143,8 +142,8 @@ tree.Definition.prototype.symbolizersToXML = function(env, symbolizers, zoom) {
}
}
}
- xml += ' \n';
- return xml;
+ if (!xml) return '';
+ return ' \n' + xml + ' \n';
};
// Take a zoom range of zooms and 'i', the index of a rule in this.rules,
diff --git a/lib/carto/tree/style.js b/lib/carto/tree/style.js
index 3d90357..6a58fbf 100644
--- a/lib/carto/tree/style.js
+++ b/lib/carto/tree/style.js
@@ -38,8 +38,9 @@ tree.Style.toXML = function(name, attachment, definitions, env) {
if (opacity.length) {
attrs_xml += ' opacity="' + opacity[0].value.eval(env).toString() + '" ';
}
-
- return '';
+ var rule_string = rules.join('');
+ if (!attrs_xml && !rule_string) return '';
+ return '';
};
})(require('../tree'));
\ No newline at end of file
diff --git a/test/rendering-mss.test.js b/test/rendering-mss.test.js
index f7787f8..2d31a5d 100644
--- a/test/rendering-mss.test.js
+++ b/test/rendering-mss.test.js
@@ -7,7 +7,7 @@ var carto = require('../lib/carto');
var tree = require('../lib/carto/tree');
var helper = require('./support/helper');
-/*
+
describe('Rendering mss', function() {
helper.files('rendering-mss', 'mss', function(file) {
@@ -43,4 +43,3 @@ helper.files('rendering-mss', 'mss', function(file) {
});
});
-*/
\ No newline at end of file
diff --git a/test/rendering-mss/should-discard-empty-style-and-attach.xml b/test/rendering-mss/should-discard-empty-style-and-attach.xml
index e69de29..8b13789 100644
--- a/test/rendering-mss/should-discard-empty-style-and-attach.xml
+++ b/test/rendering-mss/should-discard-empty-style-and-attach.xml
@@ -0,0 +1 @@
+