Skip to content

Commit

Permalink
[UPD] use numeric values on numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
Viglino committed May 3, 2021
1 parent 3204fcf commit 367d0c1
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/control/SelectBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,21 +128,33 @@ ol_control_SelectBase.prototype._escape = function (s) {
ol_control_SelectBase.prototype._checkCondition = function (f, condition, usecase) {
if (!condition.attr) return true;
var val = f.get(condition.attr);
// Try to test numeric values
var isNumber = (Number(val) == val && Number(condition.val) == condition.val);
if (isNumber) val = Number(val);
// Check
var rex;
switch (condition.op) {
case '=':
rex = new RegExp('^'+this._escape(condition.val)+'$', usecase ? '' : 'i');
return rex.test(val);
if (isNumber) {
return val == condition.val;
} else {
rex = new RegExp('^'+this._escape(condition.val)+'$', usecase ? '' : 'i');
return rex.test(val);
}
case '!=':
rex = new RegExp('^'+this._escape(condition.val)+'$', usecase ? '' : 'i');
return !rex.test(val);
if (isNumber) {
return val != condition.val;
} else {
rex = new RegExp('^'+this._escape(condition.val)+'$', usecase ? '' : 'i');
return !rex.test(val);
}
case '<':
return val < condition.val;
case '<=':
return val <= condition.val;
case '>':
return val > condition.val;
case '>=':
case '>=':
return val >= condition.val;
case 'contain':
rex = new RegExp(this._escape(condition.val), usecase ? '' : 'i');
Expand Down

0 comments on commit 367d0c1

Please sign in to comment.