diff --git a/src/ol/expr/expression.js b/src/ol/expr/expression.js index d90eca6b0d..18508f29cf 100644 --- a/src/ol/expr/expression.js +++ b/src/ol/expr/expression.js @@ -191,32 +191,30 @@ ol.expr.lib[ol.expr.functions.LIKE] = function(value, pattern, wildCard, /** * Case insensitive comparison for equality. - * @param {string} attribute Name of the attribute. - * @param {string} value Value to test for equality. + * @param {*} first First value. + * @param {*} second Second value. * @this {ol.Feature} */ -ol.expr.lib[ol.expr.functions.IEQ] = function(attribute, value) { - var attributeValue = this.get(attribute); - if (goog.isString(value) && goog.isString(attributeValue)) { - return value.toUpperCase() == attributeValue.toUpperCase(); +ol.expr.lib[ol.expr.functions.IEQ] = function(first, second) { + if (goog.isString(first) && goog.isString(second)) { + return first.toUpperCase() == second.toUpperCase(); } else { - return value == attributeValue; + return first == second; } }; /** * Case insensitive comparison for non-equality. - * @param {string} attribute Name of the attribute. - * @param {string} value Value to test for non-equality. + * @param {*} first First value. + * @param {*} second Second value. * @this {ol.Feature} */ -ol.expr.lib[ol.expr.functions.INEQ] = function(attribute, value) { - var attributeValue = this.get(attribute); - if (goog.isString(value) && goog.isString(attributeValue)) { - return value.toUpperCase() == attributeValue.toUpperCase(); +ol.expr.lib[ol.expr.functions.INEQ] = function(first, second) { + if (goog.isString(first) && goog.isString(second)) { + return first.toUpperCase() != second.toUpperCase(); } else { - return value != attributeValue; + return first != second; } }; diff --git a/test/spec/ol/expr/expression.test.js b/test/spec/ol/expr/expression.test.js index 009f467a2e..3e6724283f 100644 --- a/test/spec/ol/expr/expression.test.js +++ b/test/spec/ol/expr/expression.test.js @@ -788,6 +788,44 @@ describe('ol.expr.lib', function() { }); + describe('ieq()', function() { + + var one = new ol.Feature({foo: 'Bar'}); + var two = new ol.Feature({bar: 'Foo'}); + + var ieq1 = parse('ieq(foo, "bar")'); + var ieq2 = parse('ieq("foo", bar)'); + + it('case-insensitive equality for an attribute', function() { + expect(evaluate(ieq1, one), true); + }); + + it('case-insensitive equality for an attribute as second argument', + function() { + expect(evaluate(ieq2, two), true); + }); + + }); + + describe('ineq()', function() { + + var one = new ol.Feature({foo: 'Bar'}); + var two = new ol.Feature({bar: 'Foo'}); + + var ieq1 = parse('ineq(foo, "bar")'); + var ieq2 = parse('ineq("foo", bar)'); + + it('case-insensitive non-equality for an attribute', function() { + expect(evaluate(ieq1, one), false); + }); + + it('case-insensitive non-equality for an attribute as second argument', + function() { + expect(evaluate(ieq2, two), false); + }); + + }); + }); describe('ol.expr.register()', function() {