Skip to content

Commit

Permalink
re-enable the standalone-mss rendering tests and fix them by avoiding…
Browse files Browse the repository at this point in the history
… empty styles and empty rules - closes less#219
  • Loading branch information
Dane Springmeyer committed Dec 22, 2012
1 parent 8846bfb commit 73e5178
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/carto/renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions lib/carto/tree/definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ function symbolizerList(sym_order) {
}

tree.Definition.prototype.symbolizersToXML = function(env, symbolizers, zoom) {
var xml = ' <Rule>\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 = [];
Expand Down Expand Up @@ -143,8 +142,8 @@ tree.Definition.prototype.symbolizersToXML = function(env, symbolizers, zoom) {
}
}
}
xml += ' </Rule>\n';
return xml;
if (!xml) return '';
return ' <Rule>\n' + xml + ' </Rule>\n';
};

// Take a zoom range of zooms and 'i', the index of a rule in this.rules,
Expand Down
5 changes: 3 additions & 2 deletions lib/carto/tree/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 '<Style name="' + name + '" filter-mode="first" ' + attrs_xml + '>\n' + rules.join('') + '</Style>';
var rule_string = rules.join('');
if (!attrs_xml && !rule_string) return '';
return '<Style name="' + name + '" filter-mode="first" ' + attrs_xml + '>\n' + rule_string + '</Style>';
};

})(require('../tree'));
3 changes: 1 addition & 2 deletions test/rendering-mss.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -43,4 +43,3 @@ helper.files('rendering-mss', 'mss', function(file) {
});
});

*/
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

0 comments on commit 73e5178

Please sign in to comment.