Merge pull request #12565 from sebakerckhof/fix/12564

Handle named colors as string in equal operator
This commit is contained in:
Andreas Hocevar
2021-08-01 10:32:06 +02:00
committed by GitHub
2 changed files with 7 additions and 0 deletions

View File

@@ -606,6 +606,10 @@ function getEqualOperator(operator) {
);
}
// Since it's not possible to have color types here, we can leave it out
// This fixes issues in case the value type is ambiguously detected as a color (e.g. the string 'red')
type = type ^ ValueTypes.COLOR;
return `(${expressionToGlsl(
context,
args[0],

View File

@@ -250,6 +250,9 @@ describe('ol.style.expressions', function () {
expect(expressionToGlsl(context, ['==', 10, ['get', 'attr4']])).to.eql(
'(10.0 == a_attr4)'
);
expect(expressionToGlsl(context, ['==', 'red', ['get', 'attr4']])).to.eql(
`(${stringToGlsl(context, 'red')} == a_attr4)`
);
expect(expressionToGlsl(context, ['!=', 10, ['get', 'attr4']])).to.eql(
'(10.0 != a_attr4)'
);