Merge branch 'master' into support-multiple-values
This commit is contained in:
commit
34bd0a045d
@ -92,6 +92,9 @@ tree.Filterset.prototype.toJS = function(env) {
|
|||||||
val = filter._val.toString(true);
|
val = filter._val.toString(true);
|
||||||
}
|
}
|
||||||
var attrs = "data";
|
var attrs = "data";
|
||||||
|
if (op === '=~') {
|
||||||
|
return "(" + attrs + "['" + filter.key.value + "'] + '').match(" + (val.is === 'string' ? "'" + val.toString().replace(/'/g, "\\'") + "'" : val) + ")";
|
||||||
|
}
|
||||||
return attrs + "['" + filter.key.value + "'] " + op + " " + (val.is === 'string' ? "'" + val.toString().replace(/'/g, "\\'") + "'" : val);
|
return attrs + "['" + filter.key.value + "'] " + op + " " + (val.is === 'string' ? "'" + val.toString().replace(/'/g, "\\'") + "'" : val);
|
||||||
}).join(' && ');
|
}).join(' && ');
|
||||||
};
|
};
|
||||||
|
@ -195,4 +195,33 @@ describe('RenderingJS', function() {
|
|||||||
assert.equal(width, 8);
|
assert.equal(width, 8);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should not throw `ReferenceError` with `=~` operator", function(){
|
||||||
|
var css = [
|
||||||
|
'#layer[name=~".*wadus*"] {',
|
||||||
|
' marker-width: 14;',
|
||||||
|
'}'
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
|
assert.doesNotThrow(function () {
|
||||||
|
var shader = (new carto.RendererJS({})).render(css);
|
||||||
|
var layer = shader.getLayers()[0];
|
||||||
|
var value = layer.shader['marker-width'].style({ name: 'wadus' }, { zoom: 1 });
|
||||||
|
assert.equal(value, 14);
|
||||||
|
}, ReferenceError);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("`=~` operator should support numbers", function(){
|
||||||
|
var css = [
|
||||||
|
'#layer[value=~"^10"] {',
|
||||||
|
' marker-width: 14;',
|
||||||
|
'}'
|
||||||
|
].join('\n');
|
||||||
|
|
||||||
|
assert.doesNotThrow(function () {
|
||||||
|
var shader = (new carto.RendererJS({})).render(css);
|
||||||
|
var layer = shader.getLayers()[0];
|
||||||
|
var value = layer.shader['marker-width'].style({ value: 10 }, { zoom: 1 });
|
||||||
|
assert.equal(value, 14);
|
||||||
|
}, Error);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user