Skip to content

Commit edb4b57

Browse files
stepankuzmingithub-actions[bot]
authored andcommitted
Include featuresets in Style#serialize output (internal-8828)
GitOrigin-RevId: ff8ab5ecda95d2494b6c4c87421ac748cd6ca963
1 parent 5da76c8 commit edb4b57

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

src/style/style.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3215,6 +3215,7 @@ class Style extends Evented<MapEvents> {
32153215
metadata: this.stylesheet.metadata,
32163216
fragment: this.stylesheet.fragment,
32173217
iconsets: this.stylesheet.iconsets,
3218+
featuresets: this.stylesheet.featuresets,
32183219
imports: this._serializeImports(),
32193220
schema: this.stylesheet.schema,
32203221
camera: this.stylesheet.camera,

test/unit/style/style_imports.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3339,7 +3339,8 @@ test('Style#serialize', async () => {
33393339
sources: {'mapbox-dem': {type: 'raster-dem', tiles: ['http://example.com/{z}/{x}/{y}.png']}},
33403340
terrain: {source: 'mapbox-dem', exaggeration: 1.5},
33413341
projection: {name: 'globe'},
3342-
transition: {duration: 900, delay: 200}
3342+
transition: {duration: 900, delay: 200},
3343+
featuresets: {'test-featureset': {selectors: [{layer: 'background'}]}}
33433344
});
33443345

33453346
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
@@ -3359,6 +3360,7 @@ test('Style#serialize', async () => {
33593360
expect(serialized.terrain).toBeFalsy();
33603361
expect(serialized.projection).toBeFalsy();
33613362
expect(serialized.transition).toBeFalsy();
3363+
expect(serialized.featuresets).toBeFalsy();
33623364
expect(serialized.sources).toEqual({});
33633365

33643366
resolve();

test/unit/ui/map/getStyle.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,4 +174,22 @@ describe('Map#getStyle', () => {
174174
map.setStyle(style, {diff: false});
175175
expect(map.style && map.style !== previousStyle).toBeTruthy();
176176
});
177+
178+
test('returns the style with featuresets', async () => {
179+
const style = createStyle();
180+
style['featuresets'] = {
181+
'my-featureset': {
182+
'selectors': [{'layer': 'background'}]
183+
}
184+
};
185+
style['layers'] = [{'id': 'background', 'type': 'background'}];
186+
const map = createMap({style});
187+
188+
await waitFor(map, 'load');
189+
expect(map.getStyle().featuresets).toEqual({
190+
'my-featureset': {
191+
'selectors': [{'layer': 'background'}]
192+
}
193+
});
194+
});
177195
});

0 commit comments

Comments
 (0)