Merge pull request #1102 from tschaub/expr-lib
Always use ol.expr.lib when calling evaluateFeature.
This commit is contained in:
@@ -21,14 +21,11 @@ goog.require('ol.geom.GeometryType');
|
||||
* @return {*} The result of the expression.
|
||||
*/
|
||||
ol.expr.evaluateFeature = function(expr, opt_feature) {
|
||||
var result;
|
||||
var scope;
|
||||
if (goog.isDef(opt_feature)) {
|
||||
result = expr.evaluate(
|
||||
opt_feature.getAttributes(), ol.expr.lib, opt_feature);
|
||||
} else {
|
||||
result = expr.evaluate();
|
||||
scope = opt_feature.getAttributes();
|
||||
}
|
||||
return result;
|
||||
return expr.evaluate(scope, ol.expr.lib, opt_feature);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -675,17 +675,20 @@ describe('ol.expr.lib', function() {
|
||||
});
|
||||
|
||||
describe('counter()', function() {
|
||||
var counter = parse('counter()');
|
||||
var counterWithStart = parse('counter(1000)');
|
||||
var start = evaluate(counter);
|
||||
|
||||
it('increases the counter with every call', function() {
|
||||
var counter = parse('counter()');
|
||||
var start = evaluate(counter);
|
||||
expect(evaluate(counter)).to.be(start + 1);
|
||||
expect(evaluate(counter)).to.be(start + 2);
|
||||
});
|
||||
|
||||
it('increases the counter, starting with a custom value', function() {
|
||||
expect(evaluate(counterWithStart)).to.be(start + 3 + 1000);
|
||||
var counterWithStart = parse('counter(1000)');
|
||||
var start = evaluate(counterWithStart);
|
||||
expect(start > 1000).to.be(true);
|
||||
expect(evaluate(counterWithStart)).to.be(start + 1);
|
||||
expect(evaluate(counterWithStart)).to.be(start + 2);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user