Skip to content

Commit

Permalink
Merge pull request #15802 from sebakerckhof/fix/ambiguous-match-input…
Browse files Browse the repository at this point in the history
…-type

fix: webgl style regression - force ambiguous match input type to an accepted type
  • Loading branch information
ahocevar committed May 7, 2024
2 parents cbe7677 + addedd3 commit faccc50
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ol/expr/expression.js
Expand Up @@ -874,6 +874,7 @@ function parseMatchArgs(encoded, context, parsedArgs, typeHint) {
`, got ${typeName(inputType)} instead`,
);
}
inputType &= expectedInputType;
if (isType(outputType, NoneType)) {
throw new Error(
`Could not find a common output type for the following match operation: ` +
Expand Down
22 changes: 22 additions & 0 deletions test/browser/spec/ol/webgl/styleparser.test.js
Expand Up @@ -1073,6 +1073,28 @@ describe('ol.webgl.styleparser', () => {
});
});

describe('handle ambiguous match input', () => {
it('parses a match', () => {
const result = parseLiteralStyle({
'icon-src':
'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==',
'icon-color': [
'match',
['get', 'foo'],
'green',
[251, 173, 21, 0.5],
'red',
[251, 173, 21, 0.5],
[251, 173, 21, 0.5],
],
});

expect(result.attributes.foo.callback({get: () => 'green'})).to.be.a(
'number',
);
});
});

describe('shader functions', () => {
it('adds shader functions in the vertex and fragment shaders', () => {
const result = parseLiteralStyle({
Expand Down

0 comments on commit faccc50

Please sign in to comment.