Skip to content

Commit

Permalink
Fix the serialization of paint classes
Browse files Browse the repository at this point in the history
fixes #2107
  • Loading branch information
Lucas Wojciechowski committed Feb 11, 2016
1 parent 5ee71a4 commit c33f075
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion js/style/style_layer.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ StyleLayer.prototype = {
};

for (var klass in this._paintDeclarations) {
var key = klass === '' ? 'paint' : 'paint.' + key;
var key = klass === '' ? 'paint' : 'paint.' + klass;
output[key] = util.mapObject(this._paintDeclarations[klass], getDeclarationValue);
}

Expand Down
18 changes: 17 additions & 1 deletion test/js/style/style_layer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,25 @@ test('StyleLayer#serialize', function(t) {
t.end();
});

t.test('serializes layers with paint classes', function(t) {
var layer = createSymbolLayer({
'paint.night': {
'text-color': 'orange'
}
});
t.deepEqual(
StyleLayer.create(layer).serialize(),
layer
);
t.end();
});

t.test('serializes refed layers', function(t) {
t.deepEqual(
StyleLayer.create(createRefedSymbolLayer(), createSymbolLayer()).serialize(),
StyleLayer.create(
createRefedSymbolLayer(),
StyleLayer.create(createSymbolLayer())
).serialize(),
createRefedSymbolLayer()
);
t.end();
Expand Down

0 comments on commit c33f075

Please sign in to comment.