Fix byFilter regression

master-undefined-tagcontent
Tom MacWright 11 years ago
parent afac483b35
commit bbeff81a16

@ -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);
}
}

@ -2,7 +2,7 @@
[type='primary'] {
line-color: red;
}
[foo='bar'] {
[foo='bar'] {
line-width: 10;
}
}
@ -14,4 +14,4 @@
[foo='bar'] {
line-width: 10;
}
}
}

@ -1,4 +1,4 @@
<Style name="style" filter-mode="first" >
<Style name="style" filter-mode="first">
<Rule>
<Filter>([foo] = 'bar') and ([type] = 'primary')</Filter>
<LineSymbolizer stroke-width="10" stroke="#ff0000" />
@ -12,7 +12,7 @@
<LineSymbolizer stroke="#ff0000" />
</Rule>
</Style>
<Style name="style-outline" filter-mode="first" >
<Style name="style-outline" filter-mode="first">
<Rule>
<Filter>([foo] = 'bar') and ([type] = 'primary')</Filter>
<LineSymbolizer stroke-width="10" stroke="#ff0000" />

Loading…
Cancel
Save