Skip to content

Commit

Permalink
fix #6501, fix moving layer to it's current location
Browse files Browse the repository at this point in the history
  • Loading branch information
ansis committed Apr 19, 2018
1 parent 0a53a14 commit b0ba8bd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/style/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,10 @@ class Style extends Evented {
return;
}

if (id === before) {
return;
}

const index = this._order.indexOf(id);
this._order.splice(index, 1);

Expand Down
17 changes: 17 additions & 0 deletions test/unit/style/style.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,23 @@ test('Style#moveLayer', (t) => {
});
});

t.test('moves to existing location', (t) => {
const style = new Style(new StubMap());
style.loadJSON(createStyleJSON({
layers: [
{id: 'a', type: 'background'},
{id: 'b', type: 'background'},
{id: 'c', type: 'background'}
]
}));

style.on('style.load', () => {
style.moveLayer('b', 'b');
t.deepEqual(style._order, ['a', 'b', 'c']);
t.end();
});
});

t.end();
});

Expand Down

0 comments on commit b0ba8bd

Please sign in to comment.