Fix byFilter regression

This commit is contained in:
Tom MacWright 2013-07-09 15:00:13 -04:00
parent afac483b35
commit bbeff81a16
3 changed files with 12 additions and 7 deletions

View File

@ -228,7 +228,8 @@ carto.Renderer.prototype.render = function render(m, callback) {
//
// @param {Array} the current list of rules
// @param {Object} definition a Definition object to add to the rules
// @param {Object} byFilter an object/dictionary of existing filters
// @param {Object} byFilter an object/dictionary of existing filters. This is
// actually keyed `attachment->filter`
// @param {Object} env the current environment
function addRules(current, definition, byFilter, env) {
var newFilters = definition.filters,
@ -296,7 +297,8 @@ function inheritDefinitions(definitions, env) {
var inheritTime = +new Date();
// definitions are ordered by specificity,
// high (index 0) to low
var byAttachment = {}, byFilter = {};
var byAttachment = {},
byFilter = {};
var result = [];
var current, previous, attachment;
@ -307,19 +309,22 @@ function inheritDefinitions(definitions, env) {
});
for (var i = 0; i < definitions.length; i++) {
attachment = definitions[i].attachment;
current = [definitions[i]];
if (!byAttachment[attachment]) {
byAttachment[attachment] = [];
byAttachment[attachment].attachment = attachment;
byFilter[attachment] = {};
result.push(byAttachment[attachment]);
}
// Iterate over all subsequent rules.
for (var j = i + 1; j < definitions.length; j++) {
if (definitions[j].attachment === attachment) {
// Only inherit rules from the same attachment.
current = addRules(current, definitions[j], byFilter, env);
current = addRules(current, definitions[j], byFilter[attachment], env);
}
}