fix tests, misc cleanup
This commit is contained in:
parent
940452ace0
commit
2d709141a8
@ -36,25 +36,23 @@
|
||||
|
||||
var features = new L.FeatureGroup();
|
||||
|
||||
for (var i = 0; i < 10000; i++) {
|
||||
var marker = L.marker(getRandomLatLng(map)).addTo(features);
|
||||
}
|
||||
var marker = L.marker(getRandomLatLng(map)).addTo(features);
|
||||
|
||||
// var line = L.polyline([
|
||||
// getRandomLatLng(map),
|
||||
// getRandomLatLng(map),
|
||||
// getRandomLatLng(map)
|
||||
// ]).addTo(features);
|
||||
var line = L.polyline([
|
||||
getRandomLatLng(map),
|
||||
getRandomLatLng(map),
|
||||
getRandomLatLng(map)
|
||||
]).addTo(features);
|
||||
|
||||
// var poly = L.polygon([
|
||||
// getRandomLatLng(map),
|
||||
// getRandomLatLng(map),
|
||||
// getRandomLatLng(map),
|
||||
// getRandomLatLng(map)
|
||||
// ]).addTo(features);
|
||||
var poly = L.polygon([
|
||||
getRandomLatLng(map),
|
||||
getRandomLatLng(map),
|
||||
getRandomLatLng(map),
|
||||
getRandomLatLng(map)
|
||||
]).addTo(features);
|
||||
|
||||
features.bindPopup(function(layer){
|
||||
return layer._leaflet_id + 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec odio. Quisque volutpat mattis eros. Nullam malesuada erat ut turpis. Suspendisse urna nibh, viverra non, semper suscipit, posuere a, pede.</p><p>Donec nec justo eget felis facilisis fermentum. Aliquam porttitor mauris sit amet orci. Aenean dignissim pellentesque.';
|
||||
return 'Leaflet ID is ' + layer._leaflet_id;
|
||||
}).addTo(map);
|
||||
|
||||
L.DomUtil.get('change').onclick = function(){
|
||||
|
@ -56,9 +56,9 @@ describe('Popup', function () {
|
||||
happen.click(c);
|
||||
|
||||
// toggle open popup
|
||||
sinon.spy(marker, "openPopup");
|
||||
sinon.spy(marker, "_openPopup");
|
||||
marker.fire('click');
|
||||
expect(marker.openPopup.calledOnce).to.be(true);
|
||||
expect(marker._openPopup.calledOnce).to.be(true);
|
||||
expect(map.hasLayer(marker._popup)).to.be(true);
|
||||
marker.openPopup.restore();
|
||||
|
||||
|
@ -79,12 +79,16 @@ L.Layer.include({
|
||||
},
|
||||
|
||||
_openPopup: function (e) {
|
||||
this._popup.options.offset = this._popupAnchor(e.layer || e.target);
|
||||
if(typeof this._popup._content === 'function') {
|
||||
if(this._popup && this._map && this._map.hasLayer(this._popup) && this._popup._source === e.layer){
|
||||
this.closePopup();
|
||||
} else {
|
||||
this._popup.options.offset = this._popupAnchor(e.layer || e.target);
|
||||
this._popup._source = e.layer;
|
||||
this._popup.update();
|
||||
if(typeof this._popup._content === 'function') {
|
||||
this._popup.update();
|
||||
}
|
||||
this._map.openPopup(this._popup, e.latlng);
|
||||
}
|
||||
this._map.openPopup(this._popup, e.latlng);
|
||||
},
|
||||
|
||||
_popupAnchor: function(layer){
|
||||
|
Loading…
Reference in New Issue
Block a user