From d1de37aa88278886bfbe35eee0e8f55a4a067726 Mon Sep 17 00:00:00 2001 From: Yohan Boniface Date: Fri, 10 Jun 2016 15:36:07 +0200 Subject: [PATCH] Fix broken sizeOption when L.point instance (#4636) --- spec/suites/layer/marker/MarkerSpec.js | 16 ++++++++++++++++ src/layer/marker/Icon.js | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/spec/suites/layer/marker/MarkerSpec.js b/spec/suites/layer/marker/MarkerSpec.js index c99b288f..9b22dcc2 100644 --- a/spec/suites/layer/marker/MarkerSpec.js +++ b/spec/suites/layer/marker/MarkerSpec.js @@ -57,6 +57,22 @@ describe("Marker", function () { 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 () { var marker = new L.Marker([0, 0], {icon: icon1}); map.addLayer(marker); diff --git a/src/layer/marker/Icon.js b/src/layer/marker/Icon.js index 036beebc..4f65fd2b 100644 --- a/src/layer/marker/Icon.js +++ b/src/layer/marker/Icon.js @@ -103,7 +103,7 @@ L.Icon = L.Class.extend({ var options = this.options; var sizeOption = options[name + 'Size']; - if (!L.Util.isArray(sizeOption)) { + if (typeof sizeOption === 'number') { sizeOption = [sizeOption, sizeOption]; }