L.latLng factory not to throw error on empty array parameter
This commit is contained in:
parent
7cafaa6346
commit
c8e5d7c61b
@ -80,7 +80,10 @@ describe('LatLng', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('accepts an array of coordinates', function () {
|
it('accepts an array of coordinates', function () {
|
||||||
|
expect(L.latLng([])).to.eql(null);
|
||||||
|
expect(L.latLng([50])).to.eql(null);
|
||||||
expect(L.latLng([50, 30])).to.eql(new L.LatLng(50, 30));
|
expect(L.latLng([50, 30])).to.eql(new L.LatLng(50, 30));
|
||||||
|
expect(L.latLng([50, 30, 100])).to.eql(new L.LatLng(50, 30, 100));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('passes null or undefined as is', function () {
|
it('passes null or undefined as is', function () {
|
||||||
|
@ -61,10 +61,10 @@ L.latLng = function (a, b, c) {
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
if (L.Util.isArray(a) && typeof a[0] !== 'object') {
|
if (L.Util.isArray(a) && typeof a[0] !== 'object') {
|
||||||
if (a.length === 3) {
|
if (a.length >= 2) {
|
||||||
return new L.LatLng(a[0], a[1], a[2]);
|
return new L.LatLng(a[0], a[1], a[2]);
|
||||||
}
|
}
|
||||||
return new L.LatLng(a[0], a[1]);
|
return null;
|
||||||
}
|
}
|
||||||
if (a === undefined || a === null) {
|
if (a === undefined || a === null) {
|
||||||
return a;
|
return a;
|
||||||
|
Loading…
Reference in New Issue
Block a user