mirror of
https://github.com/Leaflet/Leaflet.git
synced 2025-07-25 15:38:54 +00:00
Remove deprecated methods / options (#9622)
This commit is contained in:
@ -634,9 +634,6 @@ describe('Events', () => {
|
|||||||
expect(spy2.calledWith({
|
expect(spy2.calledWith({
|
||||||
type: 'test2',
|
type: 'test2',
|
||||||
target: parent,
|
target: parent,
|
||||||
// layer should be deprecated in the future
|
|
||||||
// in favor of sourceTarget
|
|
||||||
layer: obj,
|
|
||||||
sourceTarget: obj,
|
sourceTarget: obj,
|
||||||
propagatedFrom: obj
|
propagatedFrom: obj
|
||||||
})).to.be.true;
|
})).to.be.true;
|
||||||
|
@ -42,15 +42,6 @@ describe('DomEvent.DoubleTapSpec.js', () => {
|
|||||||
expect(spy.notCalled).to.be.true;
|
expect(spy.notCalled).to.be.true;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not fire dblclick when detail !== 1', () => {
|
|
||||||
UIEventSimulator.fire('click', container, {detail: 0}); // like in IE
|
|
||||||
clock.tick(100);
|
|
||||||
UIEventSimulator.fire('click', container, {detail: 0});
|
|
||||||
clock.tick(100);
|
|
||||||
|
|
||||||
expect(spy.notCalled).to.be.true;
|
|
||||||
});
|
|
||||||
|
|
||||||
it('does not fire dblclick after removeListener', () => {
|
it('does not fire dblclick after removeListener', () => {
|
||||||
DomEvent.off(container, 'dblclick', spy);
|
DomEvent.off(container, 'dblclick', spy);
|
||||||
|
|
||||||
|
@ -599,20 +599,13 @@ describe('DomEvent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('#preventDefault', () => {
|
describe('#preventDefault', () => {
|
||||||
function isPrevented(e) {
|
|
||||||
if ('defaultPrevented' in e) {
|
|
||||||
return e.defaultPrevented;
|
|
||||||
}
|
|
||||||
return !e.returnValue; // IE<11
|
|
||||||
}
|
|
||||||
|
|
||||||
it('prevents the default action of event', (done) => {
|
it('prevents the default action of event', (done) => {
|
||||||
DomEvent.on(el, 'click', (e) => {
|
DomEvent.on(el, 'click', (e) => {
|
||||||
expect(isPrevented(e)).not.to.be.true; // control case
|
expect(e.defaultPrevented).not.to.be.true; // control case
|
||||||
|
|
||||||
DomEvent.preventDefault(e);
|
DomEvent.preventDefault(e);
|
||||||
|
|
||||||
expect(isPrevented(e)).to.be.true;
|
expect(e.defaultPrevented).to.be.true;
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -154,7 +154,7 @@ describe('Marker#toGeoJSON', () => {
|
|||||||
|
|
||||||
describe('Circle#toGeoJSON', () => {
|
describe('Circle#toGeoJSON', () => {
|
||||||
it('returns a 2D Point object', () => {
|
it('returns a 2D Point object', () => {
|
||||||
const circle = new Circle([10, 20], 100);
|
const circle = new Circle([10, 20], {radius: 100});
|
||||||
expect(circle.toGeoJSON().geometry).to.eql({
|
expect(circle.toGeoJSON().geometry).to.eql({
|
||||||
type: 'Point',
|
type: 'Point',
|
||||||
coordinates: [20, 10]
|
coordinates: [20, 10]
|
||||||
@ -162,7 +162,7 @@ describe('Circle#toGeoJSON', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns a 3D Point object', () => {
|
it('returns a 3D Point object', () => {
|
||||||
const circle = new Circle([10, 20, 30], 100);
|
const circle = new Circle([10, 20, 30], {radius: 100});
|
||||||
expect(circle.toGeoJSON().geometry).to.eql({
|
expect(circle.toGeoJSON().geometry).to.eql({
|
||||||
type: 'Point',
|
type: 'Point',
|
||||||
coordinates: [20, 10, 30]
|
coordinates: [20, 10, 30]
|
||||||
@ -170,7 +170,7 @@ describe('Circle#toGeoJSON', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should allow specific precisions', () => {
|
it('should allow specific precisions', () => {
|
||||||
const circle = new Circle([10.1234, 20.1234, 30.1234], 100);
|
const circle = new Circle([10.1234, 20.1234, 30.1234], {radius: 100});
|
||||||
expect(circle.toGeoJSON(3).geometry).to.eql({
|
expect(circle.toGeoJSON(3).geometry).to.eql({
|
||||||
type: 'Point',
|
type: 'Point',
|
||||||
coordinates: [20.123, 10.123, 30.123]
|
coordinates: [20.123, 10.123, 30.123]
|
||||||
|
@ -110,23 +110,23 @@ describe('ImageOverlay', () => {
|
|||||||
it('should update the z-index of the image if it has allready been added to the map', () => {
|
it('should update the z-index of the image if it has allready been added to the map', () => {
|
||||||
const overlay = imageOverlay('', imageBounds);
|
const overlay = imageOverlay('', imageBounds);
|
||||||
overlay.addTo(map);
|
overlay.addTo(map);
|
||||||
expect(overlay._image.style.zIndex).to.eql('1'); // Number type in IE
|
expect(overlay._image.style.zIndex).to.eql('1');
|
||||||
|
|
||||||
overlay.setZIndex('10');
|
overlay.setZIndex('10');
|
||||||
expect(overlay._image.style.zIndex).to.eql('10'); // Number type in IE
|
expect(overlay._image.style.zIndex).to.eql('10');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set the z-index of the image when it is added to the map', () => {
|
it('should set the z-index of the image when it is added to the map', () => {
|
||||||
const overlay = imageOverlay('', imageBounds);
|
const overlay = imageOverlay('', imageBounds);
|
||||||
overlay.setZIndex('10');
|
overlay.setZIndex('10');
|
||||||
overlay.addTo(map);
|
overlay.addTo(map);
|
||||||
expect(overlay._image.style.zIndex).to.eql('10'); // Number type in IE
|
expect(overlay._image.style.zIndex).to.eql('10');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should use the z-index specified in options', () => {
|
it('should use the z-index specified in options', () => {
|
||||||
const overlay = imageOverlay('', imageBounds, {zIndex: 20});
|
const overlay = imageOverlay('', imageBounds, {zIndex: 20});
|
||||||
overlay.addTo(map);
|
overlay.addTo(map);
|
||||||
expect(overlay._image.style.zIndex).to.eql('20'); // Number type in IE
|
expect(overlay._image.style.zIndex).to.eql('20');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be fluent', () => {
|
it('should be fluent', () => {
|
||||||
|
@ -103,7 +103,7 @@ describe('Popup', () => {
|
|||||||
// toggle popup on marker1
|
// toggle popup on marker1
|
||||||
group.fire('click', {
|
group.fire('click', {
|
||||||
latlng: center,
|
latlng: center,
|
||||||
layer: marker1
|
propagatedFrom: marker1
|
||||||
});
|
});
|
||||||
expect(map.hasLayer(group._popup)).to.be.true;
|
expect(map.hasLayer(group._popup)).to.be.true;
|
||||||
expect(group._popup._contentNode.innerHTML).to.equal('I\'m marker 1.');
|
expect(group._popup._contentNode.innerHTML).to.equal('I\'m marker 1.');
|
||||||
@ -111,7 +111,7 @@ describe('Popup', () => {
|
|||||||
// toggle popup on marker2
|
// toggle popup on marker2
|
||||||
group.fire('click', {
|
group.fire('click', {
|
||||||
latlng: [54.6, 38.2],
|
latlng: [54.6, 38.2],
|
||||||
layer: marker2
|
propagatedFrom: marker2
|
||||||
});
|
});
|
||||||
expect(map.hasLayer(group._popup)).to.be.true;
|
expect(map.hasLayer(group._popup)).to.be.true;
|
||||||
expect(group._popup._contentNode.innerHTML).to.equal('I\'m marker 2.');
|
expect(group._popup._contentNode.innerHTML).to.equal('I\'m marker 2.');
|
||||||
@ -133,7 +133,7 @@ describe('Popup', () => {
|
|||||||
// toggle popup on marker1
|
// toggle popup on marker1
|
||||||
group.fire('click', {
|
group.fire('click', {
|
||||||
latlng: center,
|
latlng: center,
|
||||||
layer: marker1
|
propagatedFrom: marker1
|
||||||
});
|
});
|
||||||
expect(map.hasLayer(group._popup)).to.be.true;
|
expect(map.hasLayer(group._popup)).to.be.true;
|
||||||
expect(group._popup._contentNode.innerHTML).to.equal('I\'m marker 1.');
|
expect(group._popup._contentNode.innerHTML).to.equal('I\'m marker 1.');
|
||||||
@ -141,7 +141,7 @@ describe('Popup', () => {
|
|||||||
// toggle popup on marker2
|
// toggle popup on marker2
|
||||||
group.fire('click', {
|
group.fire('click', {
|
||||||
latlng: [54.6, 38.2],
|
latlng: [54.6, 38.2],
|
||||||
layer: marker2
|
propagatedFrom: marker2
|
||||||
});
|
});
|
||||||
expect(map.hasLayer(group._popup)).to.be.true;
|
expect(map.hasLayer(group._popup)).to.be.true;
|
||||||
expect(group._popup._contentNode.innerHTML).to.equal('I\'m marker 2.');
|
expect(group._popup._contentNode.innerHTML).to.equal('I\'m marker 2.');
|
||||||
|
@ -17,10 +17,7 @@ describe('VideoOverlay', () => {
|
|||||||
removeMapContainer(map, container);
|
removeMapContainer(map, container);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('create VideoOverlay', () => {
|
||||||
it('create VideoOverlay', function () {
|
|
||||||
this.timeout(10000); // This test takes longer than usual in IE
|
|
||||||
|
|
||||||
const videoUrls = [
|
const videoUrls = [
|
||||||
'https://www.mapbox.com/bites/00188/patricia_nasa.webm',
|
'https://www.mapbox.com/bites/00188/patricia_nasa.webm',
|
||||||
'https://www.mapbox.com/bites/00188/patricia_nasa.mp4'
|
'https://www.mapbox.com/bites/00188/patricia_nasa.mp4'
|
||||||
|
@ -33,7 +33,7 @@ describe('Icon.Default', () => {
|
|||||||
[ // valid
|
[ // valid
|
||||||
'url("http://localhost:8000/base/dist/images/marker-icon.png")', // Firefox
|
'url("http://localhost:8000/base/dist/images/marker-icon.png")', // Firefox
|
||||||
'url(\'http://localhost:8000/base/dist/images/marker-icon.png\')',
|
'url(\'http://localhost:8000/base/dist/images/marker-icon.png\')',
|
||||||
'url(http://localhost:8000/base/dist/images/marker-icon.png)', // IE, Edge
|
'url(http://localhost:8000/base/dist/images/marker-icon.png)'
|
||||||
].map(stripUrl).forEach((str) => { expect(str).to.equal(properPath); });
|
].map(stripUrl).forEach((str) => { expect(str).to.equal(properPath); });
|
||||||
|
|
||||||
[ // invalid
|
[ // invalid
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import {expect} from 'chai';
|
import {expect} from 'chai';
|
||||||
import {Browser, CRS, DomUtil, Map, TileLayer, Util, LatLng} from 'leaflet';
|
import {Browser, CRS, Map, TileLayer, Util, LatLng} from 'leaflet';
|
||||||
import sinon from 'sinon';
|
import sinon from 'sinon';
|
||||||
import {createContainer, removeMapContainer} from '../../SpecHelper.js';
|
import {createContainer, removeMapContainer} from '../../SpecHelper.js';
|
||||||
|
|
||||||
@ -442,8 +442,7 @@ describe('TileLayer', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const _describe = 'crossOrigin' in DomUtil.create('img') ? describe : describe.skip; // skip in IE<11
|
describe('crossOrigin option', () => {
|
||||||
_describe('crossOrigin option', () => {
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
map.setView([0, 0], 2);
|
map.setView([0, 0], 2);
|
||||||
});
|
});
|
||||||
|
@ -21,13 +21,6 @@ describe('Circle', () => {
|
|||||||
const circle = new Circle([0, 0]);
|
const circle = new Circle([0, 0]);
|
||||||
expect(circle.getRadius()).to.eql(10);
|
expect(circle.getRadius()).to.eql(10);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws error if radius is NaN', () => {
|
|
||||||
expect(() => {
|
|
||||||
new Circle([0, 0], NaN);
|
|
||||||
}).to.throw('Circle radius cannot be NaN');
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#getBounds', () => {
|
describe('#getBounds', () => {
|
||||||
|
@ -188,9 +188,6 @@ export const Layers = Control.extend({
|
|||||||
container = this._container = DomUtil.create('div', className),
|
container = this._container = DomUtil.create('div', className),
|
||||||
collapsed = this.options.collapsed;
|
collapsed = this.options.collapsed;
|
||||||
|
|
||||||
// makes this work on IE touch devices by stopping it from firing a mouseout event when the touch is released
|
|
||||||
container.setAttribute('aria-haspopup', true);
|
|
||||||
|
|
||||||
DomEvent.disableClickPropagation(container);
|
DomEvent.disableClickPropagation(container);
|
||||||
DomEvent.disableScrollPropagation(container);
|
DomEvent.disableScrollPropagation(container);
|
||||||
|
|
||||||
|
@ -296,7 +296,6 @@ export const Events = {
|
|||||||
_propagateEvent(e) {
|
_propagateEvent(e) {
|
||||||
for (const p of Object.values(this._eventParents ?? {})) {
|
for (const p of Object.values(this._eventParents ?? {})) {
|
||||||
p.fire(e.type, {
|
p.fire(e.type, {
|
||||||
layer: e.target,
|
|
||||||
propagatedFrom: e.target,
|
propagatedFrom: e.target,
|
||||||
...e
|
...e
|
||||||
}, true);
|
}, true);
|
||||||
|
@ -29,8 +29,6 @@ be the same as the `target`.
|
|||||||
@property propagatedFrom: Object
|
@property propagatedFrom: Object
|
||||||
For propagated events, the last object that propagated the event to its
|
For propagated events, the last object that propagated the event to its
|
||||||
event parent.
|
event parent.
|
||||||
@property layer: Object
|
|
||||||
**Deprecated.** The same as `propagatedFrom`.
|
|
||||||
|
|
||||||
|
|
||||||
@miniclass KeyboardEvent (Event objects)
|
@miniclass KeyboardEvent (Event objects)
|
||||||
|
@ -219,22 +219,10 @@ export function stop(e) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// @function getPropagationPath(ev: DOMEvent): Array
|
// @function getPropagationPath(ev: DOMEvent): Array
|
||||||
// Compatibility polyfill for [`Event.composedPath()`](https://developer.mozilla.org/en-US/docs/Web/API/Event/composedPath).
|
|
||||||
// Returns an array containing the `HTMLElement`s that the given DOM event
|
// Returns an array containing the `HTMLElement`s that the given DOM event
|
||||||
// should propagate to (if not stopped).
|
// should propagate to (if not stopped).
|
||||||
export function getPropagationPath(ev) {
|
export function getPropagationPath(ev) {
|
||||||
if (ev.composedPath) {
|
return ev.composedPath();
|
||||||
return ev.composedPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
const path = [];
|
|
||||||
let el = ev.target;
|
|
||||||
|
|
||||||
while (el) {
|
|
||||||
path.push(el);
|
|
||||||
el = el.parentNode;
|
|
||||||
}
|
|
||||||
return path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -278,9 +266,6 @@ export function getWheelDelta(e) {
|
|||||||
(e.deltaY && e.deltaMode === 1) ? -e.deltaY * 20 : // Lines
|
(e.deltaY && e.deltaMode === 1) ? -e.deltaY * 20 : // Lines
|
||||||
(e.deltaY && e.deltaMode === 2) ? -e.deltaY * 60 : // Pages
|
(e.deltaY && e.deltaMode === 2) ? -e.deltaY * 60 : // Pages
|
||||||
(e.deltaX || e.deltaZ) ? 0 : // Skip horizontal/depth wheel events
|
(e.deltaX || e.deltaZ) ? 0 : // Skip horizontal/depth wheel events
|
||||||
e.wheelDelta ? (e.wheelDeltaY || e.wheelDelta) / 2 : // Legacy IE pixels
|
|
||||||
(e.detail && Math.abs(e.detail) < 32765) ? -e.detail * 20 : // Legacy Moz lines
|
|
||||||
e.detail ? e.detail / -32765 * 60 : // Legacy Moz pages
|
|
||||||
0;
|
0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,11 +154,6 @@ export const Draggable = Evented.extend({
|
|||||||
document.body.classList.add('leaflet-dragging');
|
document.body.classList.add('leaflet-dragging');
|
||||||
|
|
||||||
this._lastTarget = e.target ?? e.srcElement;
|
this._lastTarget = e.target ?? e.srcElement;
|
||||||
// IE and Edge do not give the <use> element, so fetch it
|
|
||||||
// if necessary
|
|
||||||
if (window.SVGElementInstance && this._lastTarget instanceof window.SVGElementInstance) {
|
|
||||||
this._lastTarget = this._lastTarget.correspondingUseElement;
|
|
||||||
}
|
|
||||||
this._lastTarget.classList.add('leaflet-drag-target');
|
this._lastTarget.classList.add('leaflet-drag-target');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,9 +8,8 @@ import {toTransformation} from '../../geometry/Transformation.js';
|
|||||||
*
|
*
|
||||||
* A common CRS among GIS enthusiasts. Uses simple Equirectangular projection.
|
* A common CRS among GIS enthusiasts. Uses simple Equirectangular projection.
|
||||||
*
|
*
|
||||||
* Leaflet 1.0.x complies with the [TMS coordinate scheme for EPSG:4326](https://wiki.osgeo.org/wiki/Tile_Map_Service_Specification#global-geodetic),
|
* Leaflet complies with the [TMS coordinate scheme for EPSG:4326](https://wiki.osgeo.org/wiki/Tile_Map_Service_Specification#global-geodetic).
|
||||||
* which is a breaking change from 0.7.x behaviour. If you are using a `TileLayer`
|
* If you are using a `TileLayer` with this CRS, ensure that there are two 256x256 pixel tiles covering the
|
||||||
* with this CRS, ensure that there are two 256x256 pixel tiles covering the
|
|
||||||
* whole earth at zoom level zero, and that the tile coordinate origin is (-180,+90),
|
* whole earth at zoom level zero, and that the tile coordinate origin is (-180,+90),
|
||||||
* or (-180,-90) for `TileLayer`s with [the `tms` option](#tilelayer-tms) set.
|
* or (-180,-90) for `TileLayer`s with [the `tms` option](#tilelayer-tms) set.
|
||||||
*/
|
*/
|
||||||
|
@ -500,7 +500,7 @@ Layer.include({
|
|||||||
// prevent map click
|
// prevent map click
|
||||||
DomEvent.stop(e);
|
DomEvent.stop(e);
|
||||||
|
|
||||||
const target = e.layer ?? e.target;
|
const target = e.propagatedFrom ?? e.target;
|
||||||
if (this._popup._source === target && !(target instanceof Path)) {
|
if (this._popup._source === target && !(target instanceof Path)) {
|
||||||
// treat it like a marker and figure out
|
// treat it like a marker and figure out
|
||||||
// if we should toggle it open/closed
|
// if we should toggle it open/closed
|
||||||
|
@ -444,7 +444,7 @@ Layer.include({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._tooltip._source = e.layer ?? e.target;
|
this._tooltip._source = e.propagatedFrom ?? e.target;
|
||||||
|
|
||||||
this.openTooltip(this._tooltip.options.sticky ? e.latlng : undefined);
|
this.openTooltip(this._tooltip.options.sticky ? e.latlng : undefined);
|
||||||
},
|
},
|
||||||
|
@ -31,7 +31,8 @@ export const IconDefault = Icon.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_getIconUrl(name) {
|
_getIconUrl(name) {
|
||||||
if (typeof IconDefault.imagePath !== 'string') { // Deprecated, backwards-compatibility only
|
// only detect once
|
||||||
|
if (!IconDefault.imagePath) {
|
||||||
IconDefault.imagePath = this._detectIconPath();
|
IconDefault.imagePath = this._detectIconPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,11 +24,7 @@ import {Earth} from '../../geo/crs/CRS.Earth.js';
|
|||||||
|
|
||||||
export const Circle = CircleMarker.extend({
|
export const Circle = CircleMarker.extend({
|
||||||
|
|
||||||
initialize(latlng, options, legacyOptions) {
|
initialize(latlng, options) {
|
||||||
if (typeof options === 'number') {
|
|
||||||
// Backwards compatibility with 0.7.x factory (latlng, radius, options?)
|
|
||||||
options = {...legacyOptions, radius: options};
|
|
||||||
}
|
|
||||||
Util.setOptions(this, options);
|
Util.setOptions(this, options);
|
||||||
this._latlng = toLatLng(latlng);
|
this._latlng = toLatLng(latlng);
|
||||||
|
|
||||||
@ -104,10 +100,6 @@ export const Circle = CircleMarker.extend({
|
|||||||
// @factory L.circle(latlng: LatLng, options?: Circle options)
|
// @factory L.circle(latlng: LatLng, options?: Circle options)
|
||||||
// Instantiates a circle object given a geographical point, and an options object
|
// Instantiates a circle object given a geographical point, and an options object
|
||||||
// which contains the circle radius.
|
// which contains the circle radius.
|
||||||
// @alternative
|
|
||||||
// @factory L.circle(latlng: LatLng, radius: Number, options?: Circle options)
|
|
||||||
// Obsolete way of instantiating a circle, for compatibility with 0.7.x code.
|
|
||||||
// Do not use in new applications or plugins.
|
|
||||||
export function circle(latlng, options, legacyOptions) {
|
export function circle(latlng, options, legacyOptions) {
|
||||||
return new Circle(latlng, options, legacyOptions);
|
return new Circle(latlng, options, legacyOptions);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user