Fix broken sizeOption when L.point instance (#4636)

This commit is contained in:
Yohan Boniface 2016-06-10 15:36:07 +02:00 committed by Iván Sánchez Ortega
parent f1f96933f0
commit d1de37aa88
2 changed files with 17 additions and 1 deletions

View File

@ -57,6 +57,22 @@ describe("Marker", function () {
expect(icon.style.height).to.be(expectedXY + 'px'); expect(icon.style.height).to.be(expectedXY + 'px');
}); });
it("set the correct x and y size attributes passing a L.Point instance", function () {
var expectedXY = 96;
var sizedIcon = new L.Icon.Default({
iconUrl: icon1._getIconUrl('icon') + '?3',
iconSize: L.point(expectedXY, expectedXY)
});
var marker = new L.Marker([0, 0], {icon: sizedIcon});
map.addLayer(marker);
var icon = marker._icon;
expect(icon.style.width).to.be(expectedXY + 'px');
expect(icon.style.height).to.be(expectedXY + 'px');
});
it("changes the icon to another image", function () { it("changes the icon to another image", function () {
var marker = new L.Marker([0, 0], {icon: icon1}); var marker = new L.Marker([0, 0], {icon: icon1});
map.addLayer(marker); map.addLayer(marker);

View File

@ -103,7 +103,7 @@ L.Icon = L.Class.extend({
var options = this.options; var options = this.options;
var sizeOption = options[name + 'Size']; var sizeOption = options[name + 'Size'];
if (!L.Util.isArray(sizeOption)) { if (typeof sizeOption === 'number') {
sizeOption = [sizeOption, sizeOption]; sizeOption = [sizeOption, sizeOption];
} }