Make latLngBounds factory return an empty bounds with not argument

Just like the constructor.

Fix #3408
This commit is contained in:
Yohan Boniface
2016-04-02 11:27:56 +02:00
parent 5795f37fe4
commit 446c02f2e7
2 changed files with 12 additions and 1 deletions

View File

@ -17,6 +17,17 @@ describe('LatLngBounds', function () {
expect(b).to.eql(a);
expect(b.getNorthWest()).to.eql(new L.LatLng(30, 12));
});
it('returns an empty bounds when not argument is given', function () {
var bounds = new L.LatLngBounds();
expect(bounds instanceof L.LatLngBounds).to.be.ok(a);
});
it('returns an empty bounds when not argument is given to factory', function () {
var bounds = L.latLngBounds();
expect(bounds instanceof L.LatLngBounds).to.be.ok(a);
});
});
describe('#extend', function () {

View File

@ -168,7 +168,7 @@ L.LatLngBounds.prototype = {
// TODO International date line?
L.latLngBounds = function (a, b) { // (LatLngBounds) or (LatLng, LatLng)
if (!a || a instanceof L.LatLngBounds) {
if (a instanceof L.LatLngBounds) {
return a;
}
return new L.LatLngBounds(a, b);