diff --git a/src/style-spec/function/convert.js b/src/style-spec/function/convert.js index b200b40cc7b..73bd7fef9f9 100644 --- a/src/style-spec/function/convert.js +++ b/src/style-spec/function/convert.js @@ -226,7 +226,7 @@ export function convertTokenString(s: string) { const literal = s.slice(pos, re.lastIndex - match[0].length); pos = re.lastIndex; if (literal.length > 0) result.push(literal); - result.push(['to-string', ['get', match[1]]]); + result.push(['get', match[1]]); } if (result.length === 1) { @@ -236,7 +236,7 @@ export function convertTokenString(s: string) { if (pos < s.length) { result.push(s.slice(pos)); } else if (result.length === 2) { - return result[1]; + return ['to-string', result[1]]; } return result; diff --git a/test/integration/expression-tests/legacy/interval/tokens-zoom/test.json b/test/integration/expression-tests/legacy/interval/tokens-zoom/test.json index 05e95024253..fed8f4f31bb 100644 --- a/test/integration/expression-tests/legacy/interval/tokens-zoom/test.json +++ b/test/integration/expression-tests/legacy/interval/tokens-zoom/test.json @@ -1,8 +1,8 @@ { - "expression": {"type": "interval", "stops": [[0, "0 {a}"], [1, "1 {b}"]]}, + "expression": {"type": "interval", "stops": [[0, "0 {a}"], [1, "{b}"]]}, "inputs": [ - [{"zoom": 0}, {"properties": {"a": "a", "b": "b"}}], - [{"zoom": 1}, {"properties": {"a": "a", "b": "b"}}], + [{"zoom": 0}, {"properties": {"a": "a", "b": 2}}], + [{"zoom": 1}, {"properties": {"a": "a", "b": 2}}], [{"zoom": 0}, {"properties": {}}] ], "propertySpec": { @@ -18,13 +18,13 @@ "isZoomConstant": false, "type": "string" }, - "outputs": ["0 a", "1 b", "0 "], + "outputs": ["0 a", "2", "0 "], "serialized": [ "step", ["zoom"], - ["concat", "0 ", ["to-string", ["get", "a"]]], + ["concat", "0 ", ["get", "a"]], 1, - ["concat", "1 ", ["to-string", ["get", "b"]]] + ["to-string", ["get", "b"]] ] } } diff --git a/test/unit/style-spec/migrate.test.js b/test/unit/style-spec/migrate.test.js index fc7c46f896e..100b5003043 100644 --- a/test/unit/style-spec/migrate.test.js +++ b/test/unit/style-spec/migrate.test.js @@ -36,11 +36,11 @@ t('converts token strings to expressions', (t) => { layers: [{ id: '1', type: 'symbol', - layout: {'text-field': 'a{x}', 'icon-image': 'b{y}'} + layout: {'text-field': 'a{x}', 'icon-image': '{y}'} }] }, spec.latest.$version); - t.deepEqual(migrated.layers[0].layout['text-field'], ['concat', 'a', ['to-string', ['get', 'x']]]); - t.deepEqual(migrated.layers[0].layout['icon-image'], ['concat', 'b', ['to-string', ['get', 'y']]]); + t.deepEqual(migrated.layers[0].layout['text-field'], ['concat', 'a', ['get', 'x']]); + t.deepEqual(migrated.layers[0].layout['icon-image'], ['to-string', ['get', 'y']]); t.end(); });