Support numbers for '=~' operator
This commit is contained in:
parent
5c4bed9593
commit
fd94fbd2e6
@ -93,7 +93,7 @@ tree.Filterset.prototype.toJS = function(env) {
|
||||
}
|
||||
var attrs = "data";
|
||||
if (op === '=~') {
|
||||
return "(typeof " + attrs + "['" + filter.key.value + "'] === 'string') && " + attrs + "['" + filter.key.value + "'].match(" + (val.is === 'string' ? "'" + val.toString().replace(/'/g, "\\'") + "'" : val) + ")";
|
||||
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(' && ');
|
||||
|
@ -197,9 +197,9 @@ describe('RenderingJS', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it("should not throw `TypeError` if left operand is not a `string` with operator `=~`", function(){
|
||||
it("`=~` operator should support numbers", function(){
|
||||
var css = [
|
||||
'#layer[name=~".*wadus*"] {',
|
||||
'#layer[value=~"^10"] {',
|
||||
' marker-width: 14;',
|
||||
'}'
|
||||
].join('\n');
|
||||
@ -207,10 +207,7 @@ describe('RenderingJS', function() {
|
||||
assert.doesNotThrow(function () {
|
||||
var shader = (new carto.RendererJS({})).render(css);
|
||||
var layer = shader.getLayers()[0];
|
||||
var value = layer.shader['marker-width'].style({ name: 1 }, { zoom: 1 });
|
||||
value = layer.shader['marker-width'].style({ name: null }, { zoom: 1 });
|
||||
value = layer.shader['marker-width'].style({ name: undefined }, { zoom: 1 });
|
||||
value = layer.shader['marker-width'].style({ name: true }, { zoom: 1 });
|
||||
});
|
||||
var value = layer.shader['marker-width'].style({ value: 10 }, { zoom: 1 });
|
||||
}, Error);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user