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);
|
||||
}
|
||||
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);
|
||||
}).join(' && ');
|
||||
};
|
||||
|
@ -4,19 +4,19 @@ var carto = require('../lib/carto');
|
||||
describe('RenderingJS', function() {
|
||||
var shader;
|
||||
var style = [
|
||||
'#world {',
|
||||
'line-width: 2;',
|
||||
'line-color: #f00;',
|
||||
'[frame-offset = 1] {',
|
||||
'line-width: 3;',
|
||||
'}',
|
||||
'[frame-offset = 2] {',
|
||||
'line-width: 3;',
|
||||
'}',
|
||||
'}',
|
||||
'',
|
||||
'#worls[frame-offset = 10] {',
|
||||
'line-width: 4;',
|
||||
'#world {',
|
||||
'line-width: 2;',
|
||||
'line-color: #f00;',
|
||||
'[frame-offset = 1] {',
|
||||
'line-width: 3;',
|
||||
'}',
|
||||
'[frame-offset = 2] {',
|
||||
'line-width: 3;',
|
||||
'}',
|
||||
'}',
|
||||
'',
|
||||
'#worls[frame-offset = 10] {',
|
||||
'line-width: 4;',
|
||||
'}'
|
||||
].join('\n');
|
||||
|
||||
@ -195,4 +195,33 @@ describe('RenderingJS', function() {
|
||||
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